- Home /
Restarting UnityPlayer inside of Android activity
I been trying my best to minimize a random hanging on scene loads. I have followed the mobile optimization page and have reduced memory significantly. But after a few scene loads, Unity will still hang. Logcat spams "Inflate error: ...". (Heap overflow?) Basically from here, Unity gets stuck loading the next scene until after a few minutes or so, then the activity gets timed out / dropped.
I been trying to handle the hanging, normally a scene takes less than 10 seconds to load. If the load gets stuck and persists for 30 seconds, I instruct Unity to call it's android activity. Which I am able to do, and currently I am simply instructing UnityPlayer and the activity to shutdown. But that's not what I want to do, I want to restart the UnityPlayer in the activity without actually re-launching the app from the OS.
I don't have much Android experience, but I do realize that traditionally in Android applications, the developer is expected to handle gl-context recreations and such, (reloading textures etc). But UnityPlayer seems to work differently. Mind you, this problem only exists in Android 2.3.x, if I use Android 4.x, everything is OK. I'm currently experimenting with onSaveInstanceState and other activity methods, but I haven't had much luck yet.
.
TLDR; Unity sometimes hangs while loading a scene, I can call activity methods from Unity. I want the activity to recreate the UnityPlayer. I want UnityPlayer to restart without the need to actually quit the activity and re-launching from the OS.
Link to forum thread: http://forum.unity3d.com/threads/149299-Restarting-UnityPlayer-inside-of-Android-activity
Your answer
Follow this Question
Related Questions
How to get Native Activity of Unity in Android NDK? 2 Answers
unity main crash 0 Answers
Game crash after splash screen (Unity Logo showup-than crash) 1 Answer
White screen freeze and crash on Android 0 Answers