Jibble

Author Topic: Can't build MonoAGS  (Read 523 times)

morganw

  • Posts: 375
Can't build MonoAGS
« on: 11 Nov 2018, 20:48 »
It looks like I'm missing a library, but where is it meant to come from?

Quote
/home/mwillcock/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(5,5): Error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVe rsion" task failed unexpectedly.
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-1196807.so
  at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_lib git2_init()
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <48079e5da5364f5db01fd1de5fb12b0d>:0
  at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <48079e5da5364f5db01fd1de5fb12b0d>:0
   --- End of inner exception stack trace ---
  at LibGit2Sharp.Core.Proxy.git_libgit2_opt s_set_search_path (LibGit2Sharp.ConfigurationLevel level, System.String path) [0x00000] in <48079e5da5364f5db01fd1de5fb12b0d>:0
  at LibGit2Sharp.GlobalSettings.SetConfigSe archPaths (LibGit2Sharp.ConfigurationLevel level, System.String[] paths) [0x0001a] in <48079e5da5364f5db01fd1de5fb12b0d>:0
  at Nerdbank.GitVersioning.VersionOracle.Op enGitRepo (System.String repoRoot) [0x00012] in <efbc9057c5b448899b5dad3e37009adb>:0
  at Nerdbank.GitVersioning.VersionOracle.Cr eate (System.String projectDirectory, System.String gitRepoDirectory, Nerdbank.GitVersioning.ICloudBuild cloudBuild, System.Nullable`1[T] overrideBuildNumberOffset, System.String projectPathRelativeToGitRepoRoot) [0x00017] in <efbc9057c5b448899b5dad3e37009adb>:0
  at Nerdbank.GitVersioning.Tasks.GetBuildVe rsion.ExecuteInner () [0x000c5] in <30a008b2694b456ca3b3951866aa1bcd>:0
  at MSBuildExtensionTask.ContextAwareTask.E xecute () [0x0005e] in <681907193732458a81da14b112e5c542>:0
  at Microsoft.Build.BackEnd.TaskExecutionHo st.Microsoft.Build.BackEnd.ITaskExecuti onHost.Execute () [0x00023] in <12215e3b02f24e078481ed2a7645c866>:0
  at Microsoft.Build.BackEnd.TaskBuilder.Exe cuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionH ost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLog gingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMo de howToExecuteTask) [0x001f6] in <12215e3b02f24e078481ed2a7645c866>:0  (MSB4018) (AGS.Engine)

tzachs

  • Local Moderator
  • Posts: 1,246
  • Parking Goat- games that goats like!
    • I can help with translating
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Can't build MonoAGS
« Reply #1 on: 11 Nov 2018, 22:58 »
I got this error as well on Ubuntu 18.04, is that where you're building from?
I haven't gotten a chance to look into it too much, but I think it's a result of this issue: https://github.com/libgit2/libgit2sharp/issues/1585

As a workaround, you should be able to bypass it by disabling Nerdbank (which is the library I use to stamp the dlls with a version). I'm not sure if just deleting version.json from the root folder would do it, or if removing the package from the project is required.

morganw

  • Posts: 375
Re: Can't build MonoAGS
« Reply #2 on: 12 Nov 2018, 00:12 »
I got this error as well on Ubuntu 18.04, is that where you're building from?
I haven't gotten a chance to look into it too much, but I think it's a result of this issue: https://github.com/libgit2/libgit2sharp/issues/1585
Thanks. This was Debian 9, but the same issue I think. I've only got libcurl3.

As a workaround, you should be able to bypass it by disabling Nerdbank (which is the library I use to stamp the dlls with a version). I'm not sure if just deleting version.json from the root folder would do it, or if removing the package from the project is required.
I removed the package and modified the function to debug print the versions, and then it built. Unfortunately I can't get the debugger to attach (this seems to be a common monodevelop problem), and running without the debugger doesn't seem to do anything (I guess the program is just exiting).

One thing I didn't think to check, what is OpenGL requirement?

tzachs

  • Local Moderator
  • Posts: 1,246
  • Parking Goat- games that goats like!
    • I can help with translating
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Can't build MonoAGS
« Reply #3 on: 12 Nov 2018, 01:29 »
Unfortunately I can't get the debugger to attach (this seems to be a common monodevelop problem)
Did you install the flatpak version? Even though it's the "recommended" version according to their website, it's actually broken with regards to dotnet standard. I was able to debug using their legacy version.
Alternatively, you can also try using Rider instead, or maybe even VS Code.

and running without the debugger doesn't seem to do anything (I guess the program is just exiting).
Did you try the release build or the debug build? You should get at least some console printouts with the debug build, or there really is something happening very early on.

One thing I didn't think to check, what is OpenGL requirement?
I'm not sure what's the minimum requirement, but it seemed to work fine with OpenGL 2.1.
A few other things to try:
* What mono version do you have installed? I currently have version 5.12.0.309.
* It might be the graphics driver. I don't know what's the situation with Debian 9, but at least on one ubuntu 16.04 machine, I had a problem with the default graphics driver, and switching (I think it was from mesa to the legacy driver) fixed it.

morganw

  • Posts: 375
Re: Can't build MonoAGS
« Reply #4 on: 12 Nov 2018, 20:45 »
Did you install the flatpak version? Even though it's the "recommended" version according to their website, it's actually broken with regards to dotnet standard. I was able to debug using their legacy version.
Alternatively, you can also try using Rider instead, or maybe even VS Code.
I installed the regular version rather than the flatpak version.

Did you try the release build or the debug build? You should get at least some console printouts with the debug build, or there really is something happening very early on.
I tried both, but I didn't seem to get anything happening except the 'GUI' thread of monodevelop using 90% of the CPU.

I'm not sure what's the minimum requirement, but it seemed to work fine with OpenGL 2.1.
A few other things to try:
* What mono version do you have installed? I currently have version 5.12.0.309.
* It might be the graphics driver. I don't know what's the situation with Debian 9, but at least on one ubuntu 16.04 machine, I had a problem with the default graphics driver, and switching (I think it was from mesa to the legacy driver) fixed it.
I think I've installed the current versions of everything, and I'm using the built-in Intel driver (so not much in the way of drivers to switch between). I've listed versions below, but I guess it could just be issues with monodevelop.

Spoiler: ShowHide
Quote
$ dotnet --info
.NET Command Line Tools (2.1.202)

Product Information:
 Version:            2.1.202
 Commit SHA-1 hash:  281caedada

Runtime Environment:
 OS Name:     debian
 OS Version:  9
 OS Platform: Linux
 RID:         debian.9-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.202/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.9
  Build    : 1632fa1589b0eee3277a8841ce1770e554ece03 7

$ mono --version
Mono JIT compiler version 5.16.0.179 (tarball Thu Oct  4 10:24:32 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
   TLS:           __thread
   SIGSEGV:       altstack
   Notifications: epoll
   Architecture:  amd64
   Disabled:      none
   Misc:          softdebug
   Interpreter:   yes
   LLVM:          yes(3.6.0svn-mono-/)
   GC:            sgen (concurrent by default)

$ glxinfo | grep "OpenGL version"
OpenGL version string: 2.1 Mesa 13.0.6

tzachs

  • Local Moderator
  • Posts: 1,246
  • Parking Goat- games that goats like!
    • I can help with translating
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Can't build MonoAGS
« Reply #5 on: 12 Nov 2018, 21:25 »
Can you add to Program.cs in DemoQuest.Desktop, as the first 2 lines of the Main method:

Code: C#
  1. Debug.Listeners.AddRange(new TraceListener[] {new ConsoleTraceListener()});
  2. Debug.WriteLine("Starting Demo");

And then after compiling the debug version, run the debug version from command-line (i.e mono /your_folder/MonoAGS/Source/Demo/DemoQuest.Desktop/bin/Debug/net461/DemoQuest.Desktop.exe)?

Do you still see nothing? Not even the "Starting Demo" line?

morganw

  • Posts: 375
Re: Can't build MonoAGS
« Reply #6 on: 12 Nov 2018, 23:17 »
Thanks, it did start. The problem was that it was indexing the system fonts, which took a couple of minutes.
It looks to be running okay now.

tzachs

  • Local Moderator
  • Posts: 1,246
  • Parking Goat- games that goats like!
    • I can help with translating
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Can't build MonoAGS
« Reply #7 on: 13 Nov 2018, 05:03 »
Wait, so does it only happen the first time, or every time?
How did you figure it out? Weird that it takes a few minutes, I wonder if there's a way to bypass it (can you track it to a line in the code?).
Thanks for taking a look.

morganw

  • Posts: 375
Re: Can't build MonoAGS
« Reply #8 on: 14 Nov 2018, 23:27 »
Just the first time, so presumably it was standard runtime behaviour to build a cache on the first run. From what it printed to the console it looked like the entire application was relaunched once it was finished scanning for fonts.

Does the actual engine rely on the built-in fonts? I'll see if I can manually remove the cache to make it re-run, but I've not managed to find much information about it online so far.

tzachs

  • Local Moderator
  • Posts: 1,246
  • Parking Goat- games that goats like!
    • I can help with translating
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Can't build MonoAGS
« Reply #9 on: 15 Nov 2018, 04:55 »
From what it printed to the console it looked like the entire application was relaunched once it was finished scanning for fonts.
The restart is something I do on purpose, as I need to install the fonts because of a bug in mono (and also: this).
And I forgot about this, but I need to refresh the cache for the font install to "pick up" after I restart, so it's my fault.
However it only took a split second in all of my tests, so curious why it takes a long time in your environment.
Here's the refresh call: https://github.com/tzachshabtay/MonoAGS/blob/d09402367f384f17bfbdaf3ccc01a8e815343d9e/Source/Engine/AGS.Engine.Desktop/Drawing/DesktopFontFamilyLoader.cs#L125

So I'm guessing to reproduce this all you need to do is delete the 2 fonts that come in the demo from ~/fonts and restart the game.

As for how to fix, well, this bug is bugging me for ages, and one of the reasons I wanted to switch to ImageSharp which loads fonts in managed code and doesn't suffer from this problem, but I did some tests and its performance was unacceptable (they did improve it since, but it still doesn't match System.Drawing performance from their benchmarks). There's also the possibility that it will work fine in dot net core, which is also on the horizon. Though even if we'll support dotnet core I'll still want to allow compiling for mono as well, so I still want to see if there's a way to make it work fast if we'll end up keeping System.Drawing.
I'm wondering if maybe the refresh is slow because you have a lot of fonts on your machine, or if it's a debian thing. Can you see how many fonts you have installed on your machine?
I also wonder if maybe there's a faster version of the command, for example maybe it's just the printouts that take a long time, and if we change fc-cache -f -v to fc-cache -v it will work faster.

Ah, I also see that you can specify a directory, so we can possibly skip rebuilding the system fonts and just build the user fonts, which will maybe solve it.
I.e, just change this line:
Code: C#
  1. ProcessStartInfo info = new ProcessStartInfo("fc-cache", "-f -v") { UseShellExecute = false };
To:
Code: C#
  1. ProcessStartInfo info = new ProcessStartInfo("fc-cache", $"-f -v {LINUX_FONT_LIBRARY}") { UseShellExecute = false };

Can you test if this works? If so, I'll push a fix. Thanks.

Does the actual engine rely on the built-in fonts?
So it's probably not related, but just for sharing, the engine will use the default system font if you didn't specify your own font, and the demo game does use the default font in some places.
« Last Edit: 15 Nov 2018, 04:57 by tzachs »

morganw

  • Posts: 375
Re: Can't build MonoAGS
« Reply #10 on: 15 Nov 2018, 22:55 »
Here is before the change:
Quote
Found assets directory at: /home/mwillcock/Build/MonoAGS/Source/Demo/DemoQuest/Assets
Loading resource from Fonts/pf_ronda_seven.ttf
Loading resource from Fonts/Pixel_Berry_08_84_Ltd.Edition.TTF
Loading resource from /home/mwillcock/Build/MonoAGS/Source/Demo/DemoQuest/bin/Debug/net461/pf_ronda_seven.ttf
Loading resource from /home/mwillcock/Build/MonoAGS/Source/Demo/DemoQuest/bin/Debug/net461/Pixel_Berry_08_84_Ltd.Edition.TTF
Refreshing font cache
/usr/share/fonts: caching, new cache contents: 0 fonts, 8 dirs
/usr/share/fonts/X11: caching, new cache contents: 0 fonts, 6 dirs
/usr/share/fonts/X11/100dpi: caching, new cache contents: 358 fonts, 0 dirs
/usr/share/fonts/X11/75dpi: caching, new cache contents: 358 fonts, 0 dirs
/usr/share/fonts/X11/Type1: caching, new cache contents: 8 fonts, 0 dirs
/usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/misc: caching, new cache contents: 59 fonts, 0 dirs
/usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs
/usr/share/fonts/cmap/adobe-cns1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-gb1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-japan1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-japan2: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/cmap/adobe-korea1: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/eot: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/eot/font-awesome: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/opentype: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/opentype/font-awesome: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/opentype/linux-libertine: caching, new cache contents: 13 fonts, 0 dirs
/usr/share/fonts/svg: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/svg/font-awesome: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 11 dirs
/usr/share/fonts/truetype/crosextra: caching, new cache contents: 8 fonts, 0 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 22 fonts, 0 dirs
/usr/share/fonts/truetype/droid: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/font-awesome: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/freefont: caching, new cache contents: 12 fonts, 0 dirs
/usr/share/fonts/truetype/gentium: caching, new cache contents: 4 fonts, 0 dirs
/usr/share/fonts/truetype/gentium-basic: caching, new cache contents: 8 fonts, 0 dirs
/usr/share/fonts/truetype/lato: caching, new cache contents: 18 fonts, 0 dirs
/usr/share/fonts/truetype/liberation: caching, new cache contents: 16 fonts, 0 dirs
/usr/share/fonts/truetype/noto: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/openoffice: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/type1: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/type1/gsfonts: caching, new cache contents: 35 fonts, 0 dirs
/usr/share/fonts/woff: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/woff/font-awesome: caching, new cache contents: 1 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/mwillcock/.local/share/fonts: skipping, no such directory
/home/mwillcock/.fonts: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts: caching, new cache contents: 0 fonts, 8 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/mwillcock/.local/share/fonts: skipping, no such directory
/home/mwillcock/.fonts: caching, new cache contents: 2 fonts, 0 dirs
/var/cache/fontconfig: not cleaning unwritable cache directory
/home/mwillcock/.cache/fontconfig: cleaning cache directory
/home/mwillcock/.fontconfig: not cleaning non-existent cache directory
/usr/bin/fc-cache: succeeded
Completed refreshing font cache, restarting...

Here is after the change (and the game still works):
Quote
Found assets directory at: /home/mwillcock/Build/MonoAGS/Source/Demo/DemoQuest/Assets
Loading resource from Fonts/pf_ronda_seven.ttf
Loading resource from Fonts/Pixel_Berry_08_84_Ltd.Edition.TTF
Loading resource from /home/mwillcock/Build/MonoAGS/Source/Demo/DemoQuest/bin/Debug/net461/pf_ronda_seven.ttf
Loading resource from /home/mwillcock/Build/MonoAGS/Source/Demo/DemoQuest/bin/Debug/net461/Pixel_Berry_08_84_Ltd.Edition.TTF
Refreshing font cache
/home/mwillcock/.fonts: caching, new cache contents: 2 fonts, 0 dirs
/home/mwillcock/.fonts: caching, new cache contents: 2 fonts, 0 dirs
/var/cache/fontconfig: not cleaning unwritable cache directory
/home/mwillcock/.cache/fontconfig: cleaning cache directory
/home/mwillcock/.fontconfig: not cleaning non-existent cache directory
/usr/bin/fc-cache: succeeded
Completed refreshing font cache, restarting...

tzachs

  • Local Moderator
  • Posts: 1,246
  • Parking Goat- games that goats like!
    • I can help with translating
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Can't build MonoAGS
« Reply #11 on: 16 Nov 2018, 19:29 »
Thanks, I'll merge this soon then (hopefully the time it takes now is also acceptable).

morganw

  • Posts: 375
Re: Can't build MonoAGS
« Reply #12 on: 16 Nov 2018, 22:22 »
Yes, it is a lot faster. Although some of the slowness will probably be down to the 'vintage' of my laptop. :)