leafi / fix-spacechem-os-x

Script/instructions to fix SpaceChem for OS X 10.11
MIT License
40 stars 4 forks source link

Running into a problem with the GOG version #9

Open brechtm opened 8 years ago

brechtm commented 8 years ago

I tried to apply your fix to the GOG version of SpaceChem. The real SpaceChem.app is actually contained in GOG's SpaceChem.app at

Spacechem.app/Contents/Resources/game/Spacechem.app/Contents/Resources/SpaceChem.app

After copying over the SDL frameworks and the MonoKickstart files, running SpaceChem results in this:

$ Resources/SpaceChem.bin.osx
WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v4.0.30319
The game experienced an error. A report has been saved:
"/Users/brechtm/.local/share/Zachtronics Industries/SpaceChem/crashes/002.zicrash"

Unhandled Exception:
System.Runtime.Serialization.SerializationException: Type 'Newtonsoft.Json.JsonReaderException' in Assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' is not marked as serializable.

Server stack trace:
  at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize (System.Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) <0x2513770 + 0x0052b> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize (System.Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) <0x25132c0 + 0x0005b> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize (System.Object graph, System.Runtime.Remoting.Messaging.Header[] inHeaders, System.Runtime.Serialization.Formatters.Binary.__BinaryWriter serWriter, Boolean fCheck) <0x25112a0 + 0x0057b> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers, Boolean fCheck) <0x2510078 + 0x00117> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers) <0x2510038 + 0x0002f> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) <0x2510000 + 0x00027> in <filename unknown>:0
  at System.Runtime.Remoting.RemotingServices.SerializeExceptionData (System.Exception ex) <0x879d658 + 0x0007b> in <filename unknown>:0

Exception rethrown at [0]:

  at (wrapper xdomain-invoke) System.AppDomain:ExecuteAssembly (string,System.Security.Policy.Evidence,string[])
  at (wrapper remoting-invoke-with-check) System.AppDomain:ExecuteAssembly (string,System.Security.Policy.Evidence,string[])
  at #=q8QxSB3XrRUrcNEOZIEOatAyKrmnPJyPNuyqRLSxh4L4=.#=qgBIADda3joj6XtVTeaFk_A== (System.String[] #=q8bJkUGK$zhK06u03EiGD2A==) <0xf27f78 + 0x000e7> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Runtime.Serialization.SerializationException: Type 'Newtonsoft.Json.JsonReaderException' in Assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' is not marked as serializable.

Server stack trace:
  at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize (System.Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) <0x2513770 + 0x0052b> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize (System.Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) <0x25132c0 + 0x0005b> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize (System.Object graph, System.Runtime.Remoting.Messaging.Header[] inHeaders, System.Runtime.Serialization.Formatters.Binary.__BinaryWriter serWriter, Boolean fCheck) <0x25112a0 + 0x0057b> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers, Boolean fCheck) <0x2510078 + 0x00117> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers) <0x2510038 + 0x0002f> in <filename unknown>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) <0x2510000 + 0x00027> in <filename unknown>:0
  at System.Runtime.Remoting.RemotingServices.SerializeExceptionData (System.Exception ex) <0x879d658 + 0x0007b> in <filename unknown>:0

Exception rethrown at [0]:

  at (wrapper xdomain-invoke) System.AppDomain:ExecuteAssembly (string,System.Security.Policy.Evidence,string[])
  at (wrapper remoting-invoke-with-check) System.AppDomain:ExecuteAssembly (string,System.Security.Policy.Evidence,string[])
  at #=q8QxSB3XrRUrcNEOZIEOatAyKrmnPJyPNuyqRLSxh4L4=.#=qgBIADda3joj6XtVTeaFk_A== (System.String[] #=q8bJkUGK$zhK06u03EiGD2A==) <0xf27f78 + 0x000e7> in <filename unknown>:0

I was hoping you would have a clue about how to fix this.

brechtm commented 8 years ago

Looking at the exception.txt from the zicrash archive, I found out that there was a missing SDL_mixer softlink in the SDL_mixer Framework (it did include a broken SDL_mixer.framework link, however - not sure why that isn't causing trouble for others). After creating that link, exception.txt contains:

Exception:
#=qHtbb9WEEwqcAvlHJdDqC2UM1t0P9K9QqC5R7Y$V2jW4=: GlyphSheet: No clean breaks found between glyph rows.
  at #=qkM5C8VFtbTbWE7nlyRqPDw==.#=qpgFec2MjWhg7bVJlx9e$SA== () <0x2d6a8a8 + 0x00273> in <filename unknown>:0 
  at #=qDj3_TG1XXmlXYhsJcRX8a2ea44jSqKBadnaiItJlSIM=.#=q2kJMOFTQ8lMgmArDKe5Hfg== (#=qkM5C8VFtbTbWE7nlyRqPDw== #=q4oFpVl2ogVP4UaEwEpZmRQ==) <0x2d69a48 + 0x0008f> in <filename unknown>:0 

Thread: , State: Running, Alive: True, Background: False
  at #=qGJ7G9igE0GxBtc53u$am5w==+#=qns$SI8mNeDa_ImH68lXqk$we9Tsi2PayJBqofQy38AA=.#=qm$IBmQ$vduncXWAn03CbE$p6sJ1WCqtoWIM_gdgTnOk= (System.Threading.Thread #=qbnSCU9c5DyZbhX_aCtnFog==) [0x00000] in <filename unknown>:0 
  at #=qGJ7G9igE0GxBtc53u$am5w==.#=qLHMzM1kdTll79zgI8$m$hQ== (System.Exception #=q2SoIewfTwhbva5qbj6Cb9g==, System.String #=qSqv3s8taB8Ba3fBG_cWmpg==, System.Object[] #=q$_QFjkb0aomRgLXXyGPp3g==) [0x00000] in <filename unknown>:0 
  at #=qGJ7G9igE0GxBtc53u$am5w==.#=qOjx6e6Nnmu7RXVJnCwg$Dg== (System.Exception #=qLFoUTKR8Y3OaLg7ljBcblQ==) [0x00000] in <filename unknown>:0 
  at #=qDj3_TG1XXmlXYhsJcRX8a2ea44jSqKBadnaiItJlSIM=.#=q3hC3d4sJ13mH_DtJtMzSGQ== (System.Exception #=qwV17bQiEOVcVMg6_bmn2tg==) [0x00000] in <filename unknown>:0 
  at #=qDj3_TG1XXmlXYhsJcRX8a2ea44jSqKBadnaiItJlSIM=.#=q2kJMOFTQ8lMgmArDKe5Hfg== (#=qkM5C8VFtbTbWE7nlyRqPDw== #=q4oFpVl2ogVP4UaEwEpZmRQ==) [0x00000] in <filename unknown>:0 
  at #=q8QxSB3XrRUrcNEOZIEOatAyKrmnPJyPNuyqRLSxh4L4=.#=qgBIADda3joj6XtVTeaFk_A== (System.String[] #=q8bJkUGK$zhK06u03EiGD2A==) [0x00000] in <filename unknown>:0 
  at System.AppDomain.ExecuteAssembly (System.AppDomain , System.Reflection.Assembly , System.String[] ) [0x00000] in <filename unknown>:0 
  at System.AppDomain.ExecuteAssemblyInternal (System.Reflection.Assembly a, System.String[] args) [0x00000] in <filename unknown>:0 
  at System.AppDomain.ExecuteAssembly (System.String assemblyFile, System.Security.Policy.Evidence assemblySecurity, System.String[] args) [0x00000] in <filename unknown>:0 
  at #=q8QxSB3XrRUrcNEOZIEOatAyKrmnPJyPNuyqRLSxh4L4=.#=qgBIADda3joj6XtVTeaFk_A== (System.String[] #=q8bJkUGK$zhK06u03EiGD2A==) [0x00000] in <filename unknown>:0 

Thread: .locals, State: WaitSleepJoin, Alive: True, Background: False
brechtm commented 8 years ago

It seems SpaceChem was using the SDL_image.framework (a newer version?) from /Library/Frameworks. Renaming it makes SpaceChem run.

Do you know of a way to have SpaceChem ignore the frameworks installed in /Library/Frameworks?

P.S. Running SpaceChem.bin.osx from the console causes problems with mouse and text input in the game. The window doesn't get focus, so all input goes to the console. This is not an issue when running SpaceChem from Finder or Spotlight, thankfully.

brechtm commented 8 years ago

I discovered that it's possible to force Mono to use the SDL frameworks included in the app bundle.

In Contents/Resources/Tao.Sdl.dll.config, change

<dllentry os="osx" dll="../Frameworks/SDL.framework/SDL" />

to

<dllentry os="osx" dll="@executable_path/../Frameworks/SDL.framework/SDL" />

Do the same for SDL_image and SDL_mixer.

VinceSJ commented 7 years ago

Great bughunting, @brechtm! Made it very easy for me to deal with the same issues on my SpaceChem installation. Did you encounter any long-term issues after the fix? My version seems to be running fine, but I didn't play more than a level to check.

I'm going to create a new branch that should generalize to any version of SpaceChem, targeting those three issues:

brechtm commented 7 years ago

Thanks @VinceSJ. I didn't really play SpaceChem after getting it to work (also just a single level). I guess the debugging was enough of a fix for my puzzle gaming needs :-)

VinceSJ commented 7 years ago

@leafi I've been working on a new version (I'll push a branch and open a pull request when complete) that would support other installations like Humble Bundle and GOG, but I've encountered a really strange issue. Was hoping you (leafi) might be able to shed some light on it.

If I change fix-spacechem.sh to target my SpaceChem location, the script takes care of most everything. Only issues that have to be tidied up are a missing symlink (SDL_mixer) and altering the Tao.Sdl.dll.config file to point at the frameworks local to the app and not using the system frameworks. With those fixed, SpaceChem runs just fine. Yay.

This is where things get weird. I figured the easiest way to create a more generalized SpaceChem fix would be to just create a new version of the bonsai.tar.bz2 tarball with the symlink and config stuff already done. Then from there I could add on an option to the shell script that allows targeting non-Steam install locations.

So I made the changes to the tarball, then did a test run, unpacking my new version of the tarball to a fresh Humble Bundle SpaceChem install. Doesn't work.

To sum up, if I make the symlink and config file changes by hand, after the shell script unpacks the tarball, everything works fine. But if I get the shell script to unpack a modified tarball that already has the symlink and config file dealt with, SpaceChem won't run. Any idea what's going wrong here? As far as I can tell, both versions are totally identical if I look at them side-by-side.

Any pointers would be appreciated, thanks.

[P.S. Here's the exception.txt that comes out when things aren't working.]

leafi commented 6 years ago

(Oh god I'm late)

Symlink absolute vs relative path, maybe...?

leafi commented 6 years ago

Oh, and MonoKickStart's path resolving is notably different to vanilla Mono.