Serialization / Deserialization problem (crash on WP8)

Hi there. I’m trying to build my existing mobile project for Window Phone 8 and got a problem.

We’ve got the complex gamebalance data (lots of lists and folded structures) that is created in the Editor and then just loaded on the device.

It works fine for iOS / Android but fails on WP8.

When loading my main resource I’ve got the following:

Exception: Non-negative number required.

Parameter name: capacity
Type: System.ArgumentOutOfRangeException
Module: mscorlib
InnerException: <No Data>
AdditionalInfo:Invoking UnityEngine.IUnitySerializable::Unity_Deserialize method with argument count: 0
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1..ctor(Int32 capacity)
   at MY_CLASS_XXXX.Unity_Deserialize()
   at MY_CLASS_XXXX.Unity_Deserialize()
   at MY_CLASS_XXXX.Unity_Deserialize()
   at MY_CLASS_XXXX.Unity_Deserialize()
   at MY_CLASS_XXXX.Unity_Deserialize()
   at MY_CLASS_XXXX.Unity_Deserialize()
   at MY_GAMEBALANCE_MAIN_CLASS.Unity_Deserialize()
   at lambda_method(Closure , Object , Object[] , Int32 )
   at WinRTBridge.MethodTools.InvokeMethod(Object instance, Int32 methodIndex, Object[] args)
(Filename:  Line: 65)

A script behaviour has a different serialization layout when loading. (Read 888 bytes but expected 2643024 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

I’ve replaced my folded classes (which are data containers) with “MY_CLASS_XXXX”.

So, it seems that deserializer reads data resource and when getting to some List.<>, it reads some negative number where the List length is expected (my list can’t be null, I’ve checked it).

So, it seems that serialization format in Unity Editor is uncompatible with device’s Deserializer.

Any thoughts? Writing my own serialize/deserialize methods is extremely hard on the current stage of the product.

PS: And of course, I didn’t use any “#ifdef UNITY_EDITOR” directives in my balance classes.

That looks like a nasty bug. Do you mind submitting it?

Ok, I will try to isolate the bug and submit it ASAP

Thank you!

Just reported the bug.

I’ve cut off all code from the project and left only data structures. And the bug is still there - everything works in Editor and fails on a WP8 device.

Let me know if I can give any assistance.

Was there ever a solution to this thread?

Seems like the bug is still active :

…I am getting similar
issue with Windows store app with Unity 4.3.4
But I am getting System.OutOfMemoryException when “UnityEngine.IUnitySerializable::Unity_Deserialize method”

Hey Tautvydas Zilys ,

You have any idea in what version will this issue be fixed?

Thanks

Aiming for 4.5.1. No promises.

Hey Tautvydas,

Is Occlusion Culling supported in Windows Store as if I enable (Bake a scene) it. I am getting random assertion fails(crashes) like:

Assertion failed!

Program: …\New folder\SoD\bin\x86\Debug\AppX\UnityPlayer.dll
File: c:\buildagent\work\d3d49558e4d408f4…/umbraPr…efs.cpp

I also posted it on a different thread:
http://forum.unity3d.com/threads/246233-Windows-Store-App-Shader-or-Occlusion-Random-Crash?p=1628769#post1628769

Please advise!

Thanks
Deepesh