I’m working on an iOS project, targeting the iPad mini.
I’ve come to find it handy to put most of the UI textures in the Resources folder and load them with Resources.Load(), instead of assigning them manually in the editor.
Now, I’m facing an odd problem. When running the project from Xcode, it starts the app on the device, showing the launch screen and loading indicator for a while, then closes. Xcode says nothing but “Finished running XXX.app on iPad”, like it was the expected behaviour - no error code or what so ever.
I’ve stripped the project down so that I now only have my welcome screen scene and kept my Resources folder with all unnecessary resources in it. Problem still happens.
When I remove the unnecessary resources, the application starts much faster and remains open.
This makes me think the resources.assets file is fully loaded upon start, and that there’s some kind of limited time to load it fully before the app stops.
What is also weird, is that if I keep running the app multiple time, eventually, it’ll open. Letting me think it keeps loading that file from a run to the next.
I stripped the project I had problem with so that it contains :
an intro scene file with nothing but a script that loads next level on a touch
a second scene that displays some GUI elements with an OnGUI function in a script
that OnGUI uses a GUISkin, which is loaded from the Resources folder with Resources.Load()
the GUISkin references a few small textures, so far so good…
the Resources folder also contains huge textures, flagged as GUI, NPOT and not compressed (I made them really big on purpose for testing)
Result :
A huge resources.asset file (130Mb), two tiny sharedassets0.assets and sharedassets1.assets files (4kb and 5kb).
Once loaded, the first screen shows up really quickly. (it doesn’t use any of the files from the resources)
Then tapping goes to load the next level, wheel … then app closes
iPad backboardd[27] : Application ‘UIKitApplication:com.xxx.yyy[0xcee9]’ exited abnormally with signal 9: Killed: 9
My understanding is that the resources.asset file doesn’t support partial loading. So when accessing it for a few small files, it will load it all, and get us killed by the system after memory warnings…
I’m now looking at splitting everything in asset bundles to work around this.
Most likely the behavior that your application is inhibiting is because you’re running out of RAM / VRAM. Your textures are probably taking up too much space, so either try down res-ing or make sure all your textures are power of 2 to reduce memory waste.
Resources in Resources are not loaded, but they are (obviously) copied to the device, which will impact how fast your app builds and deploys.
If your program is running out of memory, you’ll get flooded with Memory Warnings on the console (they come when you still have space too, its a bit of a black box) and springboard will kill your app.
If you do have any objects in the scene referencing items directly in a resources folder (Ie, a public Texture2D assigned in the editor) they will be loaded at runtime, as will prefabs linked in the editor, and any textures (etc) on the prefabs.
Stupid question, maybe, but did you try turning it off and on again? A lot of XCode’s “quirks” can be resolved with a simple close, unplug devices, reopen, replug devices. (I’ve wasted many hours to have a “serious” problem vanish like this…) Come to think of it, I think I’ve had that one before >.>;; Another common two are “Could not connect to debugger” and “Could not find executable”
Another trick that sometimes fixes stuff like this is a Clean (Cmd + Shift + K), often mixed in with the above.
The documentation is pretty detailed about how to troubleshoot problems running on device. If the application is out of memory, then you’d get an applicationDidReceiveMemoryWarning() message. Since you do not mention this in your question, I suspect that you are getting killed because the app is taking too long to display the first frame. In this case you’ll get a killed by SpringBoard message in XCode.