LeonBlade / TreeTransplant

Stardew Valley Mod to transplant trees.
GNU General Public License v3.0
4 stars 7 forks source link

Instantly threws errors SMAPI 1.15.1 #1

Closed Patronos closed 7 years ago

Patronos commented 7 years ago

[13:34:25 INFO SMAPI] TreeTransplant 1.0.1 by James Stine | Allows you to transplant trees in game.^M [13:34:26 ERROR SMAPI] TreeTransplant failed on entry and might not work correctly. Technical details: System.InvalidOperationException: This image format is not supported ---> System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an e xception. ---> System.DllNotFoundException: libgdiplus.so at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&) at System.Drawing.GDIPlus..cctor () <0x41430e80 + 0x00153> in :0 --- End of inner exception stack trace --- at System.Drawing.Image.InitFromStream (System.IO.Stream stream) <0x41430b40 + 0x000fb> in :0 at System.Drawing.Image.LoadFromStream (System.IO.Stream stream, Boolean keepAlive) <0x41430a10 + 0x0002b> in :0 at System.Drawing.Image.FromStream (System.IO.Stream stream) <0x414309f0 + 0x0000f> in :0 at Microsoft.Xna.Framework.Graphics.Texture2D.PlatformFromStream (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.IO.Stream stream) <0x41430570 + 0x0003b> in :0
at Microsoft.Xna.Framework.Graphics.Texture2D.FromStream (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.IO.Stream stream) <0x414304d0 + 0x00027> in :0 --- End of inner exception stack trace --- at Microsoft.Xna.Framework.Graphics.Texture2D.FromStream (Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, System.IO.Stream stream) <0x414304d0 + 0x0007f> in :0 at TreeTransplant.TreeTransplant.loadTreeTexture () <0x41415600 + 0x00697> in :0 at TreeTransplant.TreeTransplant.Entry (IModHelper helper) <0x41415400 + 0x00017> in :0 at StardewModdingAPI.Program.LoadMods (StardewModdingAPI.Framework.IModMetadata[] mods, StardewModdingAPI.Framework.Serialisation.JsonHelper jsonHelper, StardewModdingAPI.Framework.SContentManager contentManager, IList`1 deprecationWarnings) <0x4137bbd0 + 0x0265e> in :0 ^M [13:34:26 TRACE SMAPI] Resetting asset cache...^M

Btw: It would be nice if the release packages won't contain these .DS-Store and __MAXOSX directories/files.

LeonBlade commented 7 years ago

What operating system are you using?

Also, the .DS_Store and __MACOSX folders are a byproduct of creating this stuff on a Mac, I didn't know they were even in the archives as they don't actually display on my computer. You're free to just delete them.

Patronos commented 7 years ago

I am on Fedora 26 (Linux) using SMAPI 1.15.1 with SDV 1.2.33

I just uninstalled the other Mods I had (Automate) but the issues still remain. Going to "Robin" won't even show anything except the normal options from ingame.

I came across the hidden OSx byproduct files after trying to figure out what went wrong with the mod. I used to have an MacBook Pro myself a few years back and those cache files produced by OSx drove me nuts :) Yes I deleted them.

There is just one png file within the Archive called "flip.png" or so... The png format looks correct to me. If I can help solving the problem somehow, then let me know...

LeonBlade commented 7 years ago

I assumed you were on Linux since the exception log shows a UNIX library, and since you mentioned you saw the Mac garbage files, I figured you were on Linux, but wanted to make sure.

So, this problem has more to do with Mono than my mod. It's the same reason why Get Dressed sucks for UNIX/FreeBSD OS like macOS and Linux distros.

I'm going to try a different way of loading the image and create a build. I just need you to test it out and let me know if it works for you. I'll reply again once the build is ready, it should only take a few minutes.

Patronos commented 7 years ago

Yep... Will do...

Pathoschild commented 7 years ago

Hi @Patronos. Make sure you have the latest version of SMAPI (currently 1.15.1) and have Mono installed on your machine. If it still doesn't work, ask in #modding on Discord and we'll help you get it working. :)

Patronos commented 7 years ago

Hi @Pathoschild SMAPI is at v 1.15.1. Mono is not installed since I don't need to compile anything (I also have an aversion in installing Mono (political reasons as a die hard linux user)). The necessary runtime is provided with SDV 1.2.33 and (with some exceptions) the majority of mods simply run out of the box. But I will give it a shot and will install mono-core to see whether this changes anything with the libgdi.so no dealing with png files...

LeonBlade commented 7 years ago

The actual problem lies in creating a Texture2D with FromStream and not the PNG file itself. I batch together the tree images to create a semi-transparent tree in one texture and not two (which would cause overlap in two textures with opacity). This doesn't have to do with the flip.png file. So, the problem is with the Mono installation

Patronos commented 7 years ago

Ok I did the following steps:

sudo dnf install mono-core

This resolved into the following dependencies for installation:

-bash-4.4$ sudo dnf install mono-core
Last metadata expiration check: 2:30:35 ago on Sun 13 Aug 2017 01:58:24 PM CEST.
Dependencies resolved.
================================================================================
 Package               Arch        Version           Repository            Size
================================================================================
Installing:
 mono-core             x86_64      4.8.0-7.fc26      updates-testing       18 M
Installing dependencies:
 libgdiplus            x86_64      4.2-3.fc26        fedora               169 k
 mono-data             x86_64      4.8.0-7.fc26      updates-testing      4.4 M
 mono-data-sqlite      x86_64      4.8.0-7.fc26      updates-testing      102 k
 mono-extras           x86_64      4.8.0-7.fc26      updates-testing      465 k
 mono-mvc              x86_64      4.8.0-7.fc26      updates-testing      483 k
 mono-wcf              x86_64      4.8.0-7.fc26      updates-testing      945 k
 mono-web              x86_64      4.8.0-7.fc26      updates-testing      2.5 M
 mono-winforms         x86_64      4.8.0-7.fc26      updates-testing      1.6 M

Transaction Summary
================================================================================
Install  9 Packages

Total download size: 29 M
Installed size: 89 M
Is this ok [y/N]: 
Operation aborted.

I aborted and installed libgdiplus only. But SMAPI threw the same exception as before. I then decided to install mono-core entirely... by issuing sudo dnf install mono-core (which lead to installing the missing packages as mentioned in the list of dependencies above).

Same issue.

-bash-4.4$ ldd /usr/lib64/libgdiplus.so.0
    linux-vdso.so.1 (0x00007ffcb17f2000)
    libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f1b9c7f8000)
    libcairo.so.2 => /lib64/libcairo.so.2 (0x00007f1b9c4d0000)
    libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f1b9c220000)
    libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f1b9c016000)
    libX11.so.6 => /lib64/libX11.so.6 (0x00007f1b9bcd8000)
    libjpeg.so.62 => /lib64/libjpeg.so.62 (0x00007f1b9ba6c000)
    libtiff.so.5 => /lib64/libtiff.so.5 (0x00007f1b9b7f7000)
    libgif.so.4 => /lib64/libgif.so.4 (0x00007f1b9b5ed000)
    libpng16.so.16 => /lib64/libpng16.so.16 (0x00007f1b9b3ba000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f1b9b1a3000)
    libexif.so.12 => /lib64/libexif.so.12 (0x00007f1b9af5e000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1b9ad3d000)
    libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f1b9aaf9000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f1b9a728000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f1b9a4b5000)
    libpixman-1.so.0 => /lib64/libpixman-1.so.0 (0x00007f1b9a210000)
    libEGL.so.1 => /lib64/libEGL.so.1 (0x00007f1b99ffd000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f1b99df7000)
    libxcb-shm.so.0 => /lib64/libxcb-shm.so.0 (0x00007f1b99bf3000)
    libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f1b999cb000)
    libxcb-render.so.0 => /lib64/libxcb-render.so.0 (0x00007f1b997bd000)
    libXext.so.6 => /lib64/libXext.so.6 (0x00007f1b995ab000)
    libGL.so.1 => /lib64/libGL.so.1 (0x00007f1b9931f000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f1b99115000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f1b98dff000)
    libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f1b98bef000)
    libjbig.so.2.1 => /lib64/libjbig.so.2.1 (0x00007f1b989e3000)
    libSM.so.6 => /lib64/libSM.so.6 (0x00007f1b987db000)
    libICE.so.6 => /lib64/libICE.so.6 (0x00007f1b985bf000)
    /lib64/ld-linux-x86-64.so.2 (0x00005589f38db000)
    libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f1b9838a000)
    libGLdispatch.so.0 => /lib64/libGLdispatch.so.0 (0x00007f1b980d4000)
    libXau.so.6 => /lib64/libXau.so.6 (0x00007f1b97ed0000)
    libGLX.so.0 => /lib64/libGLX.so.0 (0x00007f1b97c9e000)
    libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f1b97a99000)
-bash-4.4$ 

ldd clearly shows the linked in dependency of libpng16.so. But linking in something doesn't necessarily mean it's being used inside the library.

Since this is a throw-away installation, I will now gonna install the entire mono stack with all dependencies. This ends up installing 413mb of further mono requirements ontop of the 80mb downloaded before... I find this a bit overkill of dependency for SDV. But I will give it a shot.

Patronos commented 7 years ago

Ok same issue... Even with the ratstail of installation I made... Now that I have mono installed, let me see whether I may be able to get it compiled myself... Loading it inside monodevelop may be the first try I guess...

Pathoschild commented 7 years ago

@Patronos Normally this error isn't an issue on Linux (it usually affects MacOS), so I don't have a verified fix for you. That said, mono-core should be sufficient; can you try adding a symlink in the game folder to the libgdiplus.so file?

Patronos commented 7 years ago

Well I was just inside MonoDevelop playing around with the TreeTransplant code. I just symlinked the libgdiplus.so file inside the game dir - tested it - fails! symlinked it inside the lib64 dir as well - tested it - fails!

Patronos commented 7 years ago

@LeonBlade I confirm the FromStream issue. After commenting out the three lines that deals with FromStream (by xxx = null;) them, the errors are gone. Though that renders the mod unusable. But at least I'd like to give feedback on that subject.

Edit: The Transplant Tree's shows up under Robin's Shop...

Patronos commented 7 years ago

Found it! Ok following! Now I need to find the right words to summarize it!

Installing libgdiplus as RPM package for fedora will give you two files...

/usr/lib64/libgdiplus.so.0 /usr/lib64/libgdiplus.so.0.0.0

The provided System.Drawing.dll explicitly wants libgdiplus.so (no numbers after that). But then I also copied over the System.Drawing.dll from mono to the game directory... Now I need to test with a clean game installation to verify my thoughts.

In this case we may need to enchance StardewValley (The Script comming from SMAPI Mod) to test the libgdiplus.so.0 file coming in some distros and link it to libgdiplus.so (maybe inside the game dir). I will test now and report back.

Edit: The TreeTransplant 1.0.1 release works like a charm out of the box. Definately the libgdiplus issue. I will take care of that by providing a patch for SMAPI.

Patronos commented 7 years ago
--- StardewModdingAPI.orig  2017-07-11 04:15:20.000000000 +0200
+++ StardewModdingAPI   2017-08-13 19:26:23.955788527 +0200
@@ -44,10 +44,32 @@
     # choose launcher
     LAUNCHER=""
     if [ "$ARCH" == "x86_64" ]; then
+        if [ ! -h "/usr/lib64/libgdiplus.so" ] ; then
+            libgdiplus=`find "/usr/lib64" -maxdepth "1" -name "libgdiplus*" -type f -print | sort | tail -n "1"`
+
+            if [ "${libgdiplus}" == "" ] ; then
+                echo "please install libgdiplus package from your distro!"
+                exit
+            else
+                ln -sf "${libgdiplus}" "libgdiplus.so"
+            fi
+        fi
+
         ln -sf mcs.bin.x86_64 mcs
         cp StardewValley.bin.x86_64 StardewModdingAPI.bin.x86_64
         LAUNCHER="./StardewModdingAPI.bin.x86_64 $@"
     else
+        if [ ! -h "/usr/lib/libgdiplus.so" ] ; then
+            libgdiplus=`find "/usr/lib" -maxdepth "1" -name "libgdiplus*" -type f -print | sort | tail -n "1"`
+
+            if [ "${libgdiplus}" == "" ] ; then
+                echo "please install libgdiplus package from your distro!"
+                exit
+            else
+                ln -sf "${libgdiplus}" "libgdiplus.so"
+            fi
+        fi
+
         ln -sf mcs.bin.x86 mcs
         cp StardewValley.bin.x86 StardewModdingAPI.bin.x86
         LAUNCHER="./StardewModdingAPI.bin.x86 $@"

What does it do ?

It ensures that libgdiplus.so is mandatory installed. If not then it exists until the user installs it. If the mandatoryness is too tight then please remove the exit statements, so the game can be run anyways. Maybe the better option since no real terminal is opened through game load and the user may be irritated because nothing happens.

The first if [ -h /usr/lib/libgdiplus.so ] tests, whether the distribution already has libgdiplus.so installed and linked properly. If not then the find command will test whether any name variation is in use... If nothing is found then an error is spit out issuing the user to please install the package named libgdiplus to properly operate with mods written by modders. If any name variation is found then link that name variation into the games directory with the name libgdiplus.so. This should be quite functional amongst most modern linux distributions. Of course I can only test this with Fedora 26. Not BSD not Windows tested.

I hope I was helpful. And to the mod author. Please accept my appologizes but the issue was not easily coverable from a normal "users" perspective... I only wanted to play a round :)

Your mod works perfectly.

Pathoschild commented 7 years ago

@Patronos Can you create a SMAPI issue describing the issue and the proposed fix you mention above?