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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Crash on immediate restart: "Timeout while trying to pause the Unity Engine" before WIN DEATH

Discussion in 'Android' started by Traviyaki, Mar 24, 2015.

  1. Traviyaki

    Traviyaki

    Joined:
    Mar 29, 2014
    Posts:
    12
    We are observing an issue when restarting our Unity app immediately after killing it on certain Android devices, namely the LGE LG-E970 with 2GB ram.

    The only thing we see from the logs is this:

    03-24 13:53:25.955: I/ActivityManager(545): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.company.game/com.lostpolygon.unity.bluetoothmediator.player.BluetoothUnityPlayerNativeActivity u=0} from pid 1053
    ........
    03-24 13:53:27.747: W/Unity(10730): Timeout while trying to pause the Unity Engine.
    ....
    03-24 13:53:31.871: I/WindowState(545): WIN DEATH: Window{43897458 com.company.game/com.lostpolygon.unity.bluetoothmediator.player.BluetoothUnityPlayerNativeActivity paused=false}
    03-24 13:53:31.871: I/ActivityManager(545): Process com.company.game (pid 10730) has died.

    Any ideas? If you wait a few seconds after killing the app and restarting it does not seem to occur, but this does not appease our QA. :)
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    Are you running any custom Java code in the main activity's onPause method ?

    This can also mean you're doing something in the OnApplicationPause callback. In case it runs for too long the Android OS might kill your game.
     
  3. Traviyaki

    Traviyaki

    Joined:
    Mar 29, 2014
    Posts:
    12
    Tested on another device (Samsung Galaxy Tablet), I still see that same log message but it does not get terminated on that device. Hmmm....
     
  4. Andy-Block

    Andy-Block

    Joined:
    Aug 10, 2012
    Posts:
    10
    @Sir Travisty: Did you ever get to the bottom of this? We're seeing a similar message + crash on one device on certain builds.
     
  5. tcossairt

    tcossairt

    Joined:
    Dec 5, 2013
    Posts:
    129
    Its been awhile, but from what I recall I never figured out why it happens, but seem to remember that it only happens when installing via adb for testing, and our QA could not repro when installing from the store. YMMV. Good luck! (BTW I'm Sir Travisty, I must have created two accounts, doh!)
     
  6. DevStudio14

    DevStudio14

    Joined:
    Feb 13, 2019
    Posts:
    1
    Timeout while trying to pause the Unity Engine.

    Anyone with a satisfactory solution???
     
    CielWorld likes this.
  7. YD_JMysior

    YD_JMysior

    Joined:
    Aug 4, 2016
    Posts:
    52
    For me, this happened when using a custom Activity.java class (extending the UnityPlayerActivity.java as described here). One method of the custom class had mUnityPlayer.pause() call in it. When I called this method from within Unity (using Example 3 here) the "Timeout while trying to pause the Unity Engine" message occurred. From my understanding, you cannot pause Unity from within itself like this - the thread is blocking the pause. A workaround I found was to put the mUnityPlayer.pause() call on hold and call it delayed, like so:
    Code (Java):
    1. HandlerThread mBackgroundThread = new HandlerThread("FrameRateFix");
    2. mBackgroundThread.start();
    3. Handler mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
    4. mBackgroundHandler.postDelayed(pauseUnity, delay);
    This way, the thread goes back to Unity and so it can be paused "remotely" without issues.
    Hope this helps someone
     
  8. fhn-oncomfort

    fhn-oncomfort

    Joined:
    Jan 14, 2022
    Posts:
    4
    It's not ideal but you can force a crash of your app as a workaround:

    Code (CSharp):
    1. UnityEngine.Diagnostics.Utils.ForceCrash(UnityEngine.Diagnostics.ForcedCrashCategory.Abort);