Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Crash when launching game immediately after closing with Application.Quit

Discussion in 'Android' started by liortal, Jan 28, 2015.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    We are seeing a constant and easy to reproduce crash with our game on Android (using Unity 4.5.4).

    The scenario is easily reproduced by the following steps:

    1. Quit game - this calls Application.Quit()
    2. Immediately launch the game again from the launcher icon.
    The cause of the crash seems to be some low-level Unity code that probably does some cleanup and times out:

    Code (CSharp):
    1. 1-28 20:23:03.775: E/AndroidRuntime(4545): FATAL EXCEPTION: FinalizerWatchdogDaemon
    2. 01-28 20:23:03.775: E/AndroidRuntime(4545): Process: com.moonactive.pengi, PID: 4545
    3. 01-28 20:23:03.775: E/AndroidRuntime(4545): java.lang.Error: FATAL EXCEPTION [FinalizerWatchdogDaemon]
    4. 01-28 20:23:03.775: E/AndroidRuntime(4545): Unity version     : 4.5.4f1
    5. 01-28 20:23:03.775: E/AndroidRuntime(4545): Device model      : samsung SM-T700
    6. 01-28 20:23:03.775: E/AndroidRuntime(4545): Device fingerprint: samsung/klimtwifixx/klimtwifi:4.4.2/KOT49H/T700XXU1ANF9:user/release-keys
    7. 01-28 20:23:03.775: E/AndroidRuntime(4545): Caused by: java.util.concurrent.TimeoutException: com.unity3d.player.ReflectionHelper$1.finalize() timed out after 10 seconds
    8. 01-28 20:23:03.775: E/AndroidRuntime(4545):     at com.unity3d.player.ReflectionHelper.nativeProxyFinalize(Native Method)
    9. 01-28 20:23:03.775: E/AndroidRuntime(4545):     at com.unity3d.player.ReflectionHelper.a(Unknown Source)
    10. 01-28 20:23:03.775: E/AndroidRuntime(4545):     at com.unity3d.player.ReflectionHelper$1.finalize(Unknown Source)
    11. 01-28 20:23:03.775: E/AndroidRuntime(4545):     at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
    12. 01-28 20:23:03.775: E/AndroidRuntime(4545):     at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
    13. 01-28 20:23:03.775: E/AndroidRuntime(4545):     at java.lang.Thread.run(Thread.java:841)
    My questions are:

    1. Is using Application.Quit() safe? or should it be avoided ?
    2. Is this a bug in Unity, or perhaps in our code (or some plugin code ?)
    3. What can we use in the meantime (supposing Unity will not resolve this in the next 2 days :) )
     
  2. Veccu

    Veccu

    Joined:
    Aug 27, 2013
    Posts:
    6
    Did you find solution for this?
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    This was reported as bug # 667260

    I had a brief email communication with a dev from the Android team. @Yury Habets
    Unfortunately, i did not receive any updates on this issue since i posted it.

    As a workaround, we implemented this code:
    Code (CSharp):
    1. #if UNITY_ANDROID
    2. AndroidUtil.Activity.Call<bool>("moveTaskToBack", true);
    3. #else
    4. Application.Quit ();
    5. #endif
    AndroidUtil.Activity is just a short notation for getting the main activity using AndroidJavaObject.

    *Note that this does not quit the app, it merely moves the game to the background...
     
  4. Veccu

    Veccu

    Joined:
    Aug 27, 2013
    Posts:
    6
    OK. Thanks.
    I am not familiar with Unity bug tracking so where can I find that bug #667260? I didn't find it from IssueTracker NOR anything related to 'FATAL EXCEPTION: FinalizerWatchdogDaemon' either.
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    I have no idea either. Older bug reports are private maybe ? in any case, i did not receive any updates on that case...
     
  6. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    @liortal Do you still use this trick with AndroidUtil instead of Application.Quit() ? I also see lots of crashes in Google Console with the similar stack trace in Unity 5.5.5p1.
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    No, we've since moved to a different project and a different Unity version (Unity 5.5.3p1 and later 2017.1.1).

    I don't think we have that issue anymore, but i am not 100% sure.