- Home /
Serialization issue with multiple SaveGames iOS - Unity Serializer [SOLVED]
Hi
I am trying to save some of my GameObjects with whydoidoit's unity serializer. I have some kind of checkpoints (triggers) and when the character hits them the game is saved. Currently only a cube and a sphere with colliders and rigidbodies are saved.
In the editor everything is working, but the game crashes on iOS.
in xcode I get this output:
System.String doesn't implement interface System.IEnumerator
* Assertion: should not be reached at mini-trampolines.c:183
When I pass the first trigger everything gets saved properly and I can also load the game again. But when I hit the second trigger (without loading/quit) the game crashes with the above output. When I quit the game after passing the first "checkpoint" and load the level again (at this checkpoint) I can pass the second checkpoint but the game crashes later at the third checkpoint and so on.
I first thought it is because I tried to save objects with custom scripts using interfaces but I had the same issue after removing them.
The crash happens on this line:
LevelSerializer.SaveGame(name);
I also increased the trampolines in the AOT compilation options.
Does someone know this issue? I didn't find much about it and I'm currently not saving complex objects or anything. Appreciate any help
I solved this by making specific serialization code aot-safe
Yes but currently im not saving them and unity serializer uses them internal as far as I know. It should be possible to save them anyway.
Answer by SomeGuy22 · Jul 09, 2013 at 07:17 PM
Actually this appears to be a bug on the iOS side of things--FeatureCreep from Unity Forums has found out exactly why:
"This problem only occurs on iOS because it is due to a limitation in the Ahead-Of-Time (AOT) compiler that is used to compile Mono byte code into native code. Thus, your app probably runs fine in the Editor, WebPlayer, Windows, Mac, etc. But, on iOS, it will crash, sometimes the crashes will appear to be random. The reason this crash is occurring is because the IEnumerable.GetEnumerator() is being used instead of the non-generic IEnumerable.GetEnumerator() to get an enumerator object used by foreach iteration blocks. Since IEnumerable is a type of interface dispatch not supported by full AOT (see http://www.mono-project.com/AOT), the 'enumerator' returned by this method is actually a string object (I don't know why), which results in a crash."
He also has a temporary solution here until the mods can get a fix to this: http://forum.unity3d.com/threads/168019-quot-System-String-doesn-t-implement-interface-System-Collections-IEnumerator-quot-crash?p=1149128
You need to replace your IEnumerables with a AOT-safe methods (he wrote one on the forum).
Yes I found this too and tried it but since it didnt solve the problem I reduced the saved objects to some primitive gameObjects without scripts, but no success. Also if I out-comment the save codeline it stops crashing what makes me think of a bug in the unityserializer. But thank you vm for your research
Your answer
Follow this Question
Related Questions
Json . NET, iOS and AOT 1 Answer
How do i change my save "Total Coin" everytime i get more coins. 0 Answers
Serialize on iOS , that is AOT safe. 2 Answers