Windows Phone 8 deployment pros here?
Heyo,
So I've got a huge issue with my Unity game that crashes. It used to work perfectly in the last 4 months of development
but now for some reason it crashes on every second scene load. Only on WP8. Works great on Android...
I've debugged and went through everything for the last 48 hours but I just can seem to fix it.
Anyone have some good experience in deploying to WP8 that might be able provide some assistance?
Thanks!
Phillip
So I've got a huge issue with my Unity game that crashes. It used to work perfectly in the last 4 months of development
but now for some reason it crashes on every second scene load. Only on WP8. Works great on Android...
I've debugged and went through everything for the last 48 hours but I just can seem to fix it.
Anyone have some good experience in deploying to WP8 that might be able provide some assistance?
Thanks!
Phillip
Comments
Not sure if it could be the same issue, but I solved mine by reducing my texture sizes.
First place to start is check you are within memory. If it was working and now suddenly isn't that's probably a good place to start. My memory is hazy, but WP8 has partitioned memory per app, meaning there is always a hard limit on how much memory you can use, that has nothing to do with amount of memory on device. As you can see 150mb per is not a lot!
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681682(v=vs.105).aspx
If it's not that it possibly means something is dying deep in the internals of Unity and you have almost no recourse for finding the bug. In my case one crash literally traced back to a cached transform (eg var trans = this.transform) that would cause the whole game to vanish in a puff of smoke. I only managed to find this through painful line by line commenting. I seem to remember we also had issues with crashing on launch, have you tried compiling from Visual Studio? I seem to remember compiling from unity was a no go but VS on Master seemed okay. Been a long time so I really can't remember so well...
@dislekcia Not very good. No crash logged from what I can see. When I get a proper log I will post it.
@duncanbellsa I tested removing all textures but wasn't that, thanks.
@TheFuntastic I think your right about memory, gonna profile and see what usage I'm doing. 150MB WTF Microsoft!
And yes, MASTER setting to rule them all, took me a while to figure that one out.
I've really had the worst experience publishing for WP8 & W8. Issues with plugins, native calls etc.
But if can get this sorted all should be good.
Thanks again everyone! I will get back to you guys.
Also make sure you do clean up of any references between (Remember a reference to a script is a reference to the gameObject and therefore a reference to the material etc.). We had an issue where we would load a new scene but we had not done clean up of any references before hand. So just during loading our memory was doubled. The garbage collector would do a clean up after the load cycle but that was too late. By manually removing the references to game objects and the like before the load the problem went away (Thankfully).
We literally go through a list that had object handles and do the destroy and then change the reference to null. That may have been overkill but it worked.
Oh also should mention we do the following two things after all the objects are destroyed and the references cleared.
Resources.UnloadUnusedAssets();
System.GC.Collect();
To work around this I've got an empty "Loading..." scene before loading the next scene. That should work right? Def gonna try this. Tip of the day! Thanks for the help, will let you know what happens.
I was able to fix it! And I am surprised on what caused it. Well sort of.
I have a LevelManager class/gameobject.
The class has a public List<Sections> with a List<Level> inside that.
And obviously it's [Serializable]. That's the damn issue. Passing around this object with serialized data broke everything.
I don't know why. Does it try to get the data again and again?
So to fix it on this object's start I Instanciate a new object with the same class(blank no data class without serialized data)
and just assign the values from this one to that one. So now level data is in memory only I guess.
So don't really know why this happens.
Thanks to everyone who gave me some epic assistance. @TheFuntastic @tbulford
And no I wasn't doing anything crazy. It was just set: DontDestroyOnLoad(this.gameObject);
That is it, but the data was a List<> of 6 with each one having a child List<> of +- 10 each. So not that big.