Search Unity

Strange Behavior after Suspending and Resuming Game

Discussion in 'Android' started by kromenak, Aug 12, 2011.

  1. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    Hey guys,

    I'm having a strange problem with Unity where suspending the application and then resuming it on Android devices causes the game to act strangely (such as missing touches, extremely slow performance). Sometimes the game crashes during the resume process, sometimes it just sits at a black screen for a long period of time. But if the game ever resumes it is very unresponsive.

    This is using Unity 3.4 on the Nexus One. Here is the logcat information I'm receiving when this happens:

    Code (csharp):
    1.  
    2. D/FlurryAgent( 1412): startSession called
    3. D/FlurryAgent( 1412): Initializing Flurry session
    4. D/FlurryAgent( 1412): Starting new session
    5. D/FlurryAgent( 1412): Sending report to: http://data.flurry.com/aap.do
    6. D/dalvikvm( 1412): GC_FOR_MALLOC freed 680K, 48% free 3546K/6727K, external 1629K/2137K, paused 48ms
    7. D/FlurryAgent( 1412): Report successful
    8. D/FlurryAgent( 1412): Processing report response
    9. D/FlurryAgent( 1412): Done sending initial agent report
    10. D/dalvikvm(   96): GC_CONCURRENT freed 1988K, 44% free 5909K/10439K, external 2020K/2137K, paused 23ms+6ms
    11. I/ActivityManager(   96): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher } from pid 96
    12. D/Unity   ( 1412): NativeActivity save instance state: 0x2b4f08
    13. D/Unity   ( 1412): NativeActivity pause: 0x2b4f08
    14. D/FlurryAgent( 1412): Ending session
    15. V/RenderScript_jni(  192): surfaceCreated
    16. V/RenderScript_jni(  192): surfaceChanged
    17. D/Unity   ( 1412): NativeActivity window focus changed: 0x2b4f08 -- 0
    18. D/Unity   ( 1412): NativeActivity stop: 0x2b4f08
    19.  
    20. (this is where I had suspended the app)
    21.  
    22. I/ActivityManager(   96): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.HiddenVariable.BagIt/com.unity3d.player.UnityPlayerProxyActivity } from pid 192
    23. D/Unity   ( 1412): NativeActivity start: 0x2b4f08
    24. D/Unity   ( 1412): NativeActivity resume: 0x2b4f08
    25. E/libEGL  ( 1412): call to OpenGL ES API with no current context (logged once per thread)
    26. D/FlurryAgent( 1412): startSession called
    27. D/FlurryAgent( 1412): Initializing Flurry session
    28. D/FlurryAgent( 1412): Continuing previous session
    29. D/Unity   ( 1412): Creating OpenGL ES 1.x context (RGB16 565 16/0)
    30. W/AudioFlinger(   68): write blocked for 166 msecs, 17 delayed writes, thread 0xea00
    31. V/RenderScript_jni(  192): surfaceDestroyed
    32. W/ActivityManager(   96): Launch timeout has expired, giving up wake lock!
    33. W/ActivityManager(   96): Activity idle timeout for HistoryRecord{40745378 com.HiddenVariable.BagIt/com.unity3d.player.UnityPlayerNativeActivity}
    34. I/InputDispatcher(   96): Application is not responding: AppWindowToken{409286f0 token=HistoryRecord{40745378 com.HiddenVariable.BagIt/com.unity3d.player.UnityPlayerNativeActivity}}.  5005.5ms since event, 5005.3ms since wait started
    35. I/WindowManager(   96): Input event dispatching timed out sending to application AppWindowToken{409286f0 token=HistoryRecord{40745378 com.HiddenVariable.BagIt/com.unity3d.player.UnityPlayerNativeActivity}}
    36. I/Process (   96): Sending signal. PID: 1412 SIG: 3
    37. I/dalvikvm( 1412): threadid=4: reacting to signal 3
    38. I/dalvikvm( 1412): Wrote stack traces to '/data/anr/traces.txt'
    39. I/Process (   96): Sending signal. PID: 96 SIG: 3
    40. I/dalvikvm(   96): threadid=4: reacting to signal 3
    41. I/dalvikvm(   96): Wrote stack traces to '/data/anr/traces.txt'
    42. I/Process (   96): Sending signal. PID: 180 SIG: 3
    43. I/dalvikvm(  180): threadid=4: reacting to signal 3
    44. I/dalvikvm(  180): Wrote stack traces to '/data/anr/traces.txt'
    45. I/Process (   96): Sending signal. PID: 155 SIG: 3
    46. I/dalvikvm(  155): threadid=4: reacting to signal 3
    47. I/dalvikvm(  155): Wrote stack traces to '/data/anr/traces.txt'
    48. D/dalvikvm(   96): GC_EXPLICIT freed 594K, 42% free 6093K/10439K, external 1625K/2137K, paused 81ms
    49. D/Unity   ( 1412): NativeActivity window focus changed: 0x2b4f08 -- 1
    50. E/ActivityManager(   96): ANR in com.HiddenVariable.BagIt (com.HiddenVariable.BagIt/com.unity3d.player.UnityPlayerNativeActivity)
    51. E/ActivityManager(   96): Reason: keyDispatchingTimedOut
    52. E/ActivityManager(   96): Load: 3.15 / 4.66 / 5.15
    53. E/ActivityManager(   96): CPU usage from 14895ms to 0ms ago:
    54. E/ActivityManager(   96):   13% 1412/com.HiddenVariable.BagIt: 11% user + 1.5% kernel / faults: 1065 minor
    55. E/ActivityManager(   96):   6.7% 73/akmd: 0% user + 6.7% kernel
    56. E/ActivityManager(   96):   2.6% 68/mediaserver: 1.3% user + 1.2% kernel
    57. E/ActivityManager(   96):   2.2% 96/system_server: 1.1% user + 1.1% kernel / faults: 14 minor
    58. E/ActivityManager(   96):   0.4% 5/events/0: 0% user + 0.4% kernel
    59. E/ActivityManager(   96):   0.1% 155/com.android.systemui: 0% user + 0% kernel
    60. E/ActivityManager(   96):   0% 51/kondemand/0: 0% user + 0% kernel
    61. E/ActivityManager(   96):   0% 62/servicemanager: 0% user + 0% kernel
    62. E/ActivityManager(   96):   0% 180/com.android.phone: 0% user + 0% kernel / faults: 1 minor
    63. E/ActivityManager(   96):   0% 209/dhd_dpc: 0% user + 0% kernel
    64. E/ActivityManager(   96):   0% 234/wpa_supplicant: 0% user + 0% kernel
    65. E/ActivityManager(   96): 16% TOTAL: 10% user + 5.5% kernel + 0% softirq
    66. E/ActivityManager(   96): CPU usage from 412ms to 933ms later:
    67. E/ActivityManager(   96):   41% 96/system_server: 22% user + 18% kernel / faults: 21 minor
    68. E/ActivityManager(   96):     11% 103/SurfaceFlinger: 3.7% user + 7.5% kernel
    69. E/ActivityManager(   96):     9.4% 129/WindowManager: 9.4% user + 0% kernel
    70. E/ActivityManager(   96):     3.7% 131/InputDispatcher: 0% user + 3.7% kernel
    71. E/ActivityManager(   96):     1.8% 96/system_server: 0% user + 1.8% kernel
    72. E/ActivityManager(   96):     1.8% 102/Binder Thread #: 1.8% user + 0% kernel
    73. E/ActivityManager(   96):     1.8% 107/GL updater: 0% user + 1.8% kernel
    74. E/ActivityManager(   96):     1.8% 189/Binder Thread #: 1.8% user + 0% kernel
    75. E/ActivityManager(   96):     1.8% 191/Binder Thread #: 1.8% user + 0% kernel
    76. E/ActivityManager(   96):     1.8% 201/Binder Thread #: 1.8% user + 0% kernel
    77. E/ActivityManager(   96):     1.8% 276/Binder Thread #: 0% user + 1.8% kernel
    78. E/ActivityManager(   96):     1.8% 277/Binder Thread #: 0% user + 1.8% kernel
    79. E/ActivityManager(   96):     1.8% 1041/Binder Thread #: 1.8% user + 0% kernel
    80. E/ActivityManager(   96):     1.8% 1279/Binder Thread #: 1.8% user + 0% kernel
    81. E/ActivityManager(   96):   23% 1412/com.HiddenVariable.BagIt: 12% user + 10% kernel / faults: 396 minor
    82. E/ActivityManager(   96):     14% 1412/nVariable.BagIt: 5.3% user + 8.9% kernel
    83. E/ActivityManager(   96):     5.3% 1433/Thread-20: 5.3% user + 0% kernel
    84. E/ActivityManager(   96):     1.7% 1418/Binder Thread #: 1.7% user + 0% kernel
    85. E/ActivityManager(   96):     1.7% 1423/er$SensorThread: 1.7% user + 0% kernel
    86. E/ActivityManager(   96):     1.7% 1434/AudioTrackThrea: 1.7% user + 0% kernel
    87. E/ActivityManager(   96):   5.6% 73/akmd: 0% user + 5.6% kernel
    88. E/ActivityManager(   96):     7.5% 1325/akmd: 0% user + 7.5% kernel
    89. E/ActivityManager(   96):   1.3% 68/mediaserver: 0% user + 1.3% kernel
    90. E/ActivityManager(   96):     1.3% 94/Playback Thread: 0% user + 1.3% kernel
    91. E/ActivityManager(   96):   1.3% 155/com.android.systemui: 0% user + 1.3% kernel
    92. E/ActivityManager(   96):     1.3% 155/ndroid.systemui: 1.3% user + 0% kernel
    93. E/ActivityManager(   96):     1.3% 163/Binder Thread #: 1.3% user + 0% kernel
    94. E/ActivityManager(   96):   1.3% 209/dhd_dpc: 0% user + 1.3% kernel
    95. E/ActivityManager(   96): 71% TOTAL: 36% user + 34% kernel
    96. D/Unity   ( 1412): NativeActivity window focus changed: 0x2b4f08 -- 0
    97. D/Unity   ( 1412): NativeActivity window focus changed: 0x2b4f08 -- 1
    98. W/InputManagerService(   96): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4063a680
    99. I/wpa_supplicant(  234): CTRL-EVENT-STATE-CHANGE id=0 state=6 BSSID=00:00:00:00:00:00
    100. V/WifiMonitor(   96): Event [CTRL-EVENT-STATE-CHANGE id=0 state=6 BSSID=00:00:00:00:00:00]
    101. V/WifiStateTracker(   96): Changing supplicant state: COMPLETED ==> GROUP_HANDSHAKE
    102. I/wpa_supplicant(  234): WPA: Group rekeying completed with 00:18:39:da:04:b4 [GTK=TKIP]
    103. I/wpa_supplicant(  234): CTRL-EVENT-STATE-CHANGE id=0 state=7 BSSID=00:00:00:00:00:00
    104. V/WifiMonitor(   96): Event [WPA: Group rekeying completed with 00:18:39:da:04:b4 [GTK=TKIP]]
    105. V/WifiMonitor(   96): Event [CTRL-EVENT-STATE-CHANGE id=0 state=7 BSSID=00:00:00:00:00:00]
    106. V/WifiStateTracker(   96): Changing supplicant state: GROUP_HANDSHAKE ==> COMPLETED
    107. D/dalvikvm(  192): GC_EXPLICIT freed 246K, 46% free 3680K/6791K, external 5818K/7214K, paused 51ms
    108. D/dalvikvm( 1412): GC_CONCURRENT freed 560K, 46% free 3687K/6727K, external 1633K/2137K, paused 7ms+3ms
    109.  
    110.  
    Has anyone else been having issues like this?
     
  2. reedake

    reedake

    Joined:
    Jul 23, 2010
    Posts:
    4
    I am also having this problem on HTC Incredible and Samsung Nexus S. Not so much the crashes, but some touches start getting missed after the game has been suspended and resumed. This behaviour is ONLY exhibited by Unity version 3.4. Version 3.3 does not do this, and I've tested on both phones for hours to confirm this. It seems that the TouchPhase.Began phase goes missing sometimes.

    I want to move to version 3.4 for the optimized Android loading, but this glitch could be a real deal breaker. Do any Unity employees have some insight into this problem?

    Cheers,
    Matt
     
    Last edited: Aug 16, 2011
  3. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    Has anyone else had issues with this? I also hadn't seen it occur with Unity 3.3. While 3.4 does fix a lot of Android issues we were having, this sort of seems like swapping one big problem with another.
     
  4. TheGeoff

    TheGeoff

    Joined:
    May 25, 2010
    Posts:
    14
    I'm having a suspend and resume issue as well. Seems to work ok on our menu scene, but on one of our actual game scenes, we get a hang on resume. The log shows a "Launch timeout has expired, giving up wake lock!" message.
    It showed up after 3.4. Unfortunately I don't have a copy of 3.3 available to test with.

    Updated.
    I found a copy of the Unity 3.3 installer and gave it a try. It looks like 3.4 is definitely causing some issues.
     
    Last edited: Sep 2, 2011
  5. TheGeoff

    TheGeoff

    Joined:
    May 25, 2010
    Posts:
    14
    What version of Android are you using? I'm getting the error with a Nexus One running 2.3.4, while and LG Optimus I have running 2.2.1 is fine.
     
  6. chand81

    chand81

    Joined:
    Jun 2, 2011
    Posts:
    25
    I am facing this issue as well...
    It seems to be there in devices running Android 2.3
    On Android 2.2 the application works just fine.
     
  7. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Same thing happens on my Nexus One with Android 2.3.4 using Unity 3.4. It uses a very long time to resume, but then gives the "Force quit / Wait" message and sometimes crashes.

    This worked fine in Unity 3.3 though. Will perform some more tests to try to nail it down further.
     
  8. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    I've done some additional testing.

    I use EZ GUI in my project, and if I disable certain controls, like UIStateToggleBtn, UIRadioBtn, or don't do UIPanel transitions, then Suspend Resume works fine.

    However if they are enabled, it doesn't work and ends up showing a black screen, waiting, then gives the "Force quit / Wait" message. I don't remotely use those controls either, they are just enabled or disabled.

    Are you other guys also using EZ GUI or something in your scenes where it happens? If you aren't using EZ GUI, perhaps something else which does something similar "behind the scenes"...
     
  9. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    I actually am also using EZGUI, would be interesting if that is the source of the issues. If that is the problem, I wonder what in that code could possibly be killing the app? I'll check around and see if anything looks suspicious.
     
  10. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    I haven't been able to find out what exactly in EZ GUI that makes it happen, except in my project at least it has something to do with UIStateToggleBtn, UIRadioBtn or UIPanel transitions. Hopefully we'll be able to locate the culprit though! :)
     
  11. RMGK

    RMGK

    Joined:
    Sep 30, 2011
    Posts:
    75
    Having exactly the same issue. Using EZGui on Nexus One and Xoom. Will update if I find a fix with in EZGui.
     
  12. RMGK

    RMGK

    Joined:
    Sep 30, 2011
    Posts:
    75
    So I think the problem has to do with Time.realtimeSinceStartup. Sometimes it displays negative numbers and if the animation time step is relying on that, it could break. I've replaced a couple of the Time.realtimeSinceStartup delta calculations with DateTime.Now deltas in EZGui and I think I'm getting better results. I'll post any more success.
     
  13. RMGK

    RMGK

    Joined:
    Sep 30, 2011
    Posts:
    75
    Are any of you guys using flurry?
     
  14. immunitystudios

    immunitystudios

    Joined:
    Jan 3, 2009
    Posts:
    62
    I'm getting the same issues on my nexus one, whenever the game is resumed it starts missing touches and all sorts of weird stuff starts happening!
     
  15. Fawad-Asghar

    Fawad-Asghar

    Joined:
    Aug 27, 2011
    Posts:
    19
    Hey guys I figured out the the looonnnggg BLACK SCREEN problem after RESUMING the game from home screen.

    It wasnt an issue of unity 3.3 or 3.4. It just depends on which texture compressions are u using.

    If `automatic compression` is `ON` for the individual textures, u will see that the on the `Android Platform` it automatically sets it too either `Compressed ETC 4 bits` or `RGBA 16 bits` depending on if texture has alpha or not. And this is the recommended setting if u r building for android cuz both have less loading times and are optimized for Android.

    But in Unity 3.4 they gave an additional option of changing the `Global Textures Compression` on the `Build Settings` menu. So as I had made my game first on IOS, and PVRTC was working for me in IOS , so I changed them to PVRTC on the main `Build Settings` menu which is a very slow texture format for Andriod. Both in normal scene to scene loading times and when resuming from home screen of the android phone.

    Anyway, anyone else having this same problem like me can just make the texture compression to Automatic Compression on both invidual texture settings tab and also the Build Setting tab.

    This is only the solution for textures compression obviously. I will do more tests on EZGUI to see why it is causing problems.
     
  16. Fawad-Asghar

    Fawad-Asghar

    Joined:
    Aug 27, 2011
    Posts:
    19
    Yes, I have implemented Flurry in my game BUT with the help of Prime31 plugin. His plugins make things easy as a pie :)
     
  17. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Ah, in my project all compressions was set to Automatic already and Global Compression was also set to that, so that didn't affect my project, but good find!

    I haven't found the exact problem in EZ GUI yet, but instead removed all UIStateToggleBtn UIRadioBtn, and turned them into regular UIButtons, and also disabled/removed all UIPanel UIPanelManager, and instead of using EZ GUI's panel code for transitions I just used iTween to move the panels. After doing those changes it works great, no more black screen when resuming :)

    I'm still using UIButtons and UISlider, so those 2 components from EZ GUI work at least.

    But hopefully we can figure out why it happens though, as it's annoying to make these changes :/
     
  18. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    What version of EZ GUI are each of you running?

    Regarding toggles and radios, I can't think of anything distinct on those two control types which would distinguish them from a regular button, etc. I'm doing tests on Nexus One as well and am not able to reproduce the issue with any of the control types.

    I'm intrigued by the idea that it could be Time.realtimeSinceStartup though, and so if you are using transition effects on any of those controls, that might make sense.

    If someone could provide more information, or ideally, if someone could e-mail me directly with a simple scene that reproduces the issue, I'd like to test with that. Thanks!
     
  19. RMGK

    RMGK

    Joined:
    Sep 30, 2011
    Posts:
    75
    Hey guys,

    so finally, SOLUTION. If you un-comment #define USE_DELTA_TIME so that the game uses Time.deltaTime, everything works. Brady, I cant tell you why exactly but we just finished days of debugging and finally zeroed in on that. We have tested the solution quite a bit and all looks good. The problem we were fighting was "ERROR/libEGL(5790): call to OpenGL ES API with no current context (logged once per thread)" that showed up in the logcat when you would try to resume the application. kromenak found out that this fires if Unity tries to do something with the GL while suspended. Note that we were not getting the problem in Unity 3.3.
     
  20. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    That's very strange. I could see resume affecting the realtime tracking. But I'm very curious as to what this could have to do with any kind of OpenGL call, since there is no kind of rendering code, etc, inside EZAnimator. My best guess is that the animation coroutine gets called, which in turn moves an object, scales it, or changes its color value, and one of these actions causes Unity to attempt to perform some kind of render operation indirectly. The fact that this issue is not present in Unity 3.3 means it is, at least in part, a Unity issue which probably needs to be reported to them.

    Also, what version of EZ GUI was this? There is some new code in the last couple of versions that, upon suspend, also track the time elapsed during suspension, and deducts that from the time elapsed when the game is resumed. Though that still shouldn't cause an issue like the one described here though.
     
  21. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    Hey Brady, we are using EZGUI 1.07, latest version as far as we know. We've noticed an issue with Unity where realtimeSinceStartup may return negative or otherwise incorrect values. A few other people have noted this as well on Unity Answers, etc.

    Since using deltaTime instead of realtimeSinceStartup seems to have resolved this (fingers crossed!), I'd guess that the problem is not particularly with your code, but with the fact that you are using realtimeSinceStartup, which has a problem. Just to be clear, the problem does not occur when simply rendering sprites with SpriteManager or UI Elements with EZGUI. In order for the problem to manifest, something had to be animating on screen using a Do function or UIPanel transition. Since the issue seems to be OpenGL related, maybe something like FadeSprite or FadeMaterial is getting incorrect time values and causing mayhem?

    Tough to track down, but hopefully the root cause can be found!
     
  22. RMGK

    RMGK

    Joined:
    Sep 30, 2011
    Posts:
    75
    Update: I think its Time.realtimeSinceStartup in general. So I replaced all the Time.realtimeSinceStartup with DateTime.Now and its all good. Brady, its not an EZGui thing man, its why the hell does Time.realtimeSinceStartup crash Android apps on resuming :)
     
  23. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Ah, awesome find guys! Thanks! :D

    I uncommented "#define USE_DELTA_TIME" in both EZAnimator.cs SpriteAnimationPump.cs and it works great after that! :)

    By the way, Brady, I emailed you a sample project now where it happens for me, just in case you want to check it out.
     
  24. aqez

    aqez

    Joined:
    Apr 5, 2011
    Posts:
    13
    Thanks a ton for the work you guys put into finding this, good job. It has helped me out a lot.
     
  25. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Thanks for following up, everyone! Okay, so my guess then is perhaps realtimeSinceStartup is returning a negative value, or some other ungodly value, that, when used in calculations for a color value, for example, may be resulting in an invalid value, such as a negative color or something, and so OpenGL is throwing up?

    I suppose the way to test that theory would be to try catching the realtimeSinceStartup value before anything else happens, seeing what the value is, and then based on that knowledge, try clamping the color values or whatever and see if that fixes it. I haven't had a chance to try this yet as I've been away at GDC Austin, so I'll try to get on this shortly. Thanks again, everyone!
     
  26. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    I just want to say THANK YOU VERY MUCH for doing the leg work and finding a solution to this problem. I have been beating my head against the wall all day today with my game. I was encountering the same thing but it was readily apparent because when you play a video using iPhoneUtils.PlayMovie it would pause and resume the app basically making the entire app not usable after the video would return and it would only happen on Android.

    Using deltaTime in EZAnimator and SpriteAnimationPump seems to have resolved the issue.

    Thank you again, it saved my project and my mental faculty. I'm sure I could have beat my head against the wall for days without figuring this out!
     
  27. Blaxxun

    Blaxxun

    Joined:
    Oct 17, 2011
    Posts:
    2
    Unfortunately I did my best to follow the changes to apply on both EZAnimator and SpriteAnimationPump but the problem is still there, I get missing touch events after pressing home and resuming the application, only on Android. Tested on Android 2.3 and 3.2.

    If I disable all the EZGUI stuffs, then it works as intended. Now I am wondering if that can be fixed or if I need something to replace EZ GUI, which I would hate to do!
     
  28. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    If you can, hold on. Unity has acknowledged this as a bug on Android with the Time class, and a fix should be coming soon.
     
  29. wesllg

    wesllg

    Joined:
    Jan 8, 2011
    Posts:
    18
    Hi Brady,

    We have tried using the delta time workaround on Android, and while this stops the game from hanging upon resume, it will still cause skipped touches and general unresponsiveness. Non-ezgui elements of the scene appear to be fine however. Do you have any other suggestions to work around this problem or is this something that needs to be fixed on Unitys side?

    Cheers.
     
  30. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    It has to be fixed on Unity's side. It's a bug in Unity.
     
  31. viktors

    viktors

    Joined:
    Nov 7, 2011
    Posts:
    6
    So, any news regarding this bug?
     
  32. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    there was no unity update inbetween so also no fix of unity
     
  33. Fooo

    Fooo

    Joined:
    Mar 11, 2011
    Posts:
    41
    Hmm we still have this problem, usually when we come back from OpenFeint. We're using EZGUI and have uncommented the defines with no luck (as well as looking through any code that could use realtimeSinceStartup).
     
  34. Avorathol

    Avorathol

    Joined:
    Nov 16, 2011
    Posts:
    4
    I had the same problem, and this solution works perfectly for me. Thanks guys !!!
     
  35. akwok

    akwok

    Joined:
    Apr 21, 2009
    Posts:
    31
    Try to invalidate cached renderstates tied to your GL context by using GL.InvalidateState().
     
  36. Senor Beer

    Senor Beer

    Joined:
    Jul 13, 2011
    Posts:
    13

    After many tantrums with my project, I can confirm RMGK's solution does indeed fix the problem (assuming you are using EZGUI). The offending lines of code are lines 9 in EZAnimator.cs and SpriteAnimationPump.cs. Just uncomment them and add an #if UNITY_ANDROID around them.
     
  37. hamac

    hamac

    Joined:
    Dec 7, 2011
    Posts:
    3
    Im use version of 1.0.7.
    But I have Same Problem.
    I need help.
     
  38. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    @hamac, have you tried the solution recommended in this thread?
     
  39. Enzign

    Enzign

    Joined:
    Aug 20, 2010
    Posts:
    169
    That solution seems to have been working for me. Thanks for all the time that people put in to find this.
     
  40. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    48
    It looks like this problem is fixed, very fixed, in the 3.5 preview.

    I've been having the same issue, have tried everything in this post. We had actually fixed this very problem in our last project by setting #define USE_DELTA_TIME. Didn't work this time. Nor did hours of texture compression changes.

    I did find however that changing back to OpenGL 1.x from 2.0, the black screen mostly went away. Though the initial delay was still there.

    Then I tried it on the 3.5 preview. Back with OpeGL 2.0 and ZERO code changes. Previously resume would cause a 5.5 second delay, then to a black screen for about 2.5 - 3 seconds. That's over an 8 second delay trying to resume.

    A build using 3.5 and it comes back so fast I can't start my stop watch. From 8 seconds to <1.

    Thanks team unity. Hopefully 3.5 will go to release sooner than later...
     
  41. Texaggie96

    Texaggie96

    Joined:
    Jan 23, 2009
    Posts:
    81
    FYI. If you are using 3.4.2, the suggestion solution does indeed stop the hanging/crash. However, when your app resumes you will start missing touches. YMMV.

    Edit: Also with the suggested solution, ezgui animations (panels etc) will not work if you take your timescale to 0 (a popular way to pause the game). Again just a heads up and YMMV+1
     
    Last edited: Mar 7, 2012
  42. CalebFnord

    CalebFnord

    Joined:
    Nov 21, 2012
    Posts:
    7
    I'm having the same problem, but without EZGUI - I use NGUI + 2DToolkit (and only NGUI buttons seems to be effected).

    I noticed NGUI also uses the problematic realtimeSinceStartup so I'll try changing it and will update if solved.

    UPDATE: Didn't help with NGUI. Anyone else still encounters this problem with Unity 4.0 and NGUI?

    UPDATE #2 - SOLVED: Updating NGUI solved the problem - If you have this problem, it's probably a TOUCHID issue resulting from a bug in Unity when app focus is lost and regained - Write to your respective plugin coder for a workaround (EZGUI and NGUI seem to have dealt with this successfully).
     
    Last edited: Feb 24, 2013
  43. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    I'm having resume issues as well. I am not using NGUI or EZGUI but I am using 2dToolkit which uses realtimesincestartup in the tk2dbutton class.

    I'm not running into a black screen or anything but if I resume it's very laggy and I lose at least 10 fps and the buttons are sometimes unreponsive.

    UPDATE: Removing the realTimeSinceStartup fixed my problem as well. Now I just need to figure out how to pause the game without using timeScale = 0 or make the buttons work without realTimeSinceStartup :/
     
    Last edited: Feb 21, 2013