Android back button crash in first scene

Hi,

I am developing an Android app in Unity with Eclipse integration. I’ll try to describe it:

It has a “menu” scene. Basically, it’s a screen which prints “Loading” and waits for a parameter from eclipse. Depending on the parameter received, it loads a specific scene. In all other scenes, android back button was ignored by default, so I wrote code to capture the button press and quit application (it works fine). However, I’ve noticed that if I press the backbutton while “Loading” text is on screen (I have around 1-2 seconds to do that), application crashes. Moreover, I’ve noticed this also happens if I press the backbutton while on the default Unity splash screen, when execution hasn’t reached my code.

Does this issue related to this fact posted in changelog?: Android: Back button will quit the application while the first level has not yet been loaded.

Any idea?

Thanks

This also happens on all of my apps which are using Unity 4. Have you found an answer?

Same problem here. Happens during a level load with LoadLevelAsync at the moment when the framerate drops to 0 when all our scene elements are getting instantiated.

Yeah, I’m using just normal LoadLevel and if you press the back button when its almost done loading, it will exit the app. Also exits if you double/triple tap the back button when returning to the app after being brought out to a browser window.

This has been happening ever since unity 4 came out. I’m surprised this problem isnt this getting more attention. Has nobody upgraded to unity 4 or something?

I’m having the same issue. If I press back button while loading something (LoadLevel, Resources.Load, etc) it crashes.

This is the log:

D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeVideoFrameCallback:VILII
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSoftInputClosed:V
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetTouchDeltaY:VF
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetInputString:VL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetInputCanceled:VZ
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetExtras:VL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetDefaultDisplay:VI
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeResume:V
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeResize:VIIII
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRequestedAA:I
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRequested32bitDisplayBuffer:Z
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRender:Z
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeRecreateGfxState:VL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativePause:Z
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeKeysPressed:VL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeInjectEvent:ZL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeInitWWW:VL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeFocusChanged:VZ
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeFile:VL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeDone:V
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeActivityIndicatorStyle:I
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.initJni:VL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.UnitySendMessage:VLLL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetLocationStatus:VI
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeSetLocation:VFFFFDF
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeForwardEventsToDalvik:VZ
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/UnityPlayer;.nativeDeviceOrientation:VI
D/dalvikvm( 1141): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodUnblockStreaming:I
D/dalvikvm( 1141): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcess:IL
D/dalvikvm( 1141): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodInitJni:I
D/dalvikvm( 1141): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodGetInfo:II
D/dalvikvm( 1141): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodBlockStreaming:I
D/dalvikvm( 1141): Unregistering JNI method Lorg/fmod/FMODAudioDevice;.fmodProcessMicData:ILI
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/ReflectionHelper;.nativeProxyInvoke:LILL
D/dalvikvm( 1141): Unregistering JNI method Lcom/unity3d/player/ReflectionHelper;.nativeProxyFinalize:VI
I/Process ( 1141): Sending signal. PID: 1141 SIG: 9
I/WindowState(  593): WIN DEATH: Window{425c4850 u0 com.engidia.xxx/com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity}
I/ActivityManager(  593): Process com.engidia.xxx (pid 1141) has died.

Anyone knows why application dies?

Thanks.

Did you try to disable back button support before you call load level? Does it still happen?
If so I wonder if this happens in Unity 4.2.2

It’s still looks like a bug in Unity 4.3.4f1 and disabling button doesnt help

To get around this, you call PlayerPrefs.Save(), then force quit the app “Process.GetCurrentProcess().Kill()”.
When doing research for what I thought was a bug in my own code, I ended up finding out the best answer was there is a memory leak in Unity3D that DID NOT exist in Unity 4.1 and thus Androids main activity gets stuck… why Android can’t handle a memory leak correctly is beyond me, but not surprising either.