Search Unity

Restarting application after back button is pressed is slower than launching it first time

Discussion in 'Android' started by mholub, Apr 24, 2018.

  1. mholub

    mholub

    Joined:
    Oct 3, 2012
    Posts:
    123
    I am investigating some crashes and ANRs in our game appearing after user quits game with back button

    So lately we had few problems with common WTR:

    1. Run game.
    2. Quit game with back button (our custom code calls Application.Quit()) (Input.backButtonLeavesApp works the same way)
    3. Immediately run game again
    4. Something bad happens
    a) On Oreo devices it shows black screen for ~8 seconds (there is no black screen for first launch)
    b) It crashes because 3rd party activity (OneSignal) can't do something in wrong activity state
    c) It freezes (ANR) because other 3rd party library do something

    All of the problems are not reproduced if you press Home button or completely kill game in task launcher

    I found temporary workarounds to crash and ANR problems but I think "black screen" is a key to understand what's going on here. So I started to remove all native plugins and calls to "AndroidJavaObject" in our game hoping to remove black screen issue at some point.
    I removed everything somehow connected to native plugins and 8 seconds black screen is still there.

    I tried to create new unity application and I don't see the bug in fresh application.
    I tried to check other unity games, for example Angry birds evolution and it's there.
    I suppose the only thing we share with Angry Birds Evolution is Unity game engine, so it may be the bug inside Unity.

    Can somebody from Unity elaborate on that and help to understand what it the difference between first launch and onRestart?

    WTR:
    1. Use the device with 8.0+ Android. I used Google Pixel.
    2. Download Angry Birds Evolution https://play.google.com/store/apps/details?id=com.rovio.tnt&hl=en or our game https://play.google.com/store/apps/details?id=com.my.moba.ent
    3. Go through tutorial, cause Back button doesn't work in tutorial.
    4. Press back button, exit the application.
    5. Immediately run it again.
    6. See long black/white screen before splash image. Notice on first launch there is no such screen.
     
  2. AdriBlancoXoia

    AdriBlancoXoia

    Joined:
    Oct 15, 2018
    Posts:
    2
    Did you manage to solve this? I'm having a similar issue, I have a native android app from which I can open a unity scene, the first time I open it, it goes smoothly, but if I come back with the back button and enter immediately after it takes 4 to 6 seconds to enter again. I'm not doing any heavy operation after coming back, I don't understand what is happening.
     
  3. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    360
    any can stop from return button? or disable?Input.GetKeyDown (KeyCode.Escape) dont work in update
     
  4. unity_xrPBQ-2zcfd-DA

    unity_xrPBQ-2zcfd-DA

    Joined:
    Jun 15, 2018
    Posts:
    19
    Hey, can you share the back button code to go back from unity to android? And also share which unity version are you using because I am facing this crash on back button https://forum.unity.com/threads/crash-with-back-button.605983/. If you can help me that would be great. Thanks
     
unityunity