Repository: godot
Issue: Android game crashes randomly
Labels: bug,platform:android,topic:porting,needs testing,crash

**Godot version:**
Godot 3.3 Stable


**OS/device including version:**
Samsung Galaxy A50 + Android 10 (SDK 29)
and MORE



**Issue description:**
The game closes at a random moment. It could be a menu, a gameplay, or a pause.
Completely different scenes and different code.

I personally cannot reproduce the bug, but my players are reporting persistent crashes.

I checked the Google Play console and saw many of the same errors there.

There are only two of them, but they happen on a huge number of devices.

Error 1 - java.lang.NullPointerException

```
java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3654)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3806)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:83)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2267)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8167)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)
Caused by: java.lang.NullPointerException: 
  at org.godotengine.godot.Godot.onDestroy (Godot.java:727)
  at androidx.fragment.app.Fragment.performDestroy (Fragment.java:2699)
  at androidx.fragment.app.FragmentManagerImpl.moveToState (FragmentManager.java:1591)
  at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState (FragmentManager.java:1784)
  at androidx.fragment.app.BackStackRecord.executeOps (BackStackRecord.java:797)
  at androidx.fragment.app.FragmentManagerImpl.executeOps (FragmentManager.java:2625)
  at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether (FragmentManager.java:2411)
  at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute (FragmentManager.java:2366)
  at androidx.fragment.app.FragmentManagerImpl.execSingleAction (FragmentManager.java:2243)
  at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:654)
  at org.godotengine.godot.FullScreenGodotApp.onCreate (FullScreenGodotApp.java:61)
  at com.godot.game.GodotApp.onCreate (GodotApp.java:46)
  at android.app.Activity.performCreate (Activity.java:7963)
  at android.app.Activity.performCreate (Activity.java:7952)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1307)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3629)
```


Error 2 - signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

```
backtrace:
  #00  pc 000000000065b9b0  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 000000000065b724  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 000000000065ee30  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 000000000067fa3c  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 00000000002963a4  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 0000000000273e0c  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 0000000000716aa8  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 00000000008ecd50  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 00000000012e1514  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 0000000000738f40  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 0000000000739260  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 00000000000bea20  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so
  #00  pc 0000000000086e58  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/lib/arm/libgodot_android.so (Java_org_godotengine_godot_GodotLib_step+244)
  #00  pc 0000000000036137  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/oat/arm/base.odex (offset 0x36000) (org.godotengine.godot.GodotLib.audio [DEDUPED]+94)
  #00  pc 0000000000051a55  /data/app/ru.skanersoft.bunker-Ih8wKpwOkGKqr8NADWFqOw==/oat/arm/base.odex (offset 0x36000) (org.godotengine.godot.GodotRenderer.onDrawFrame+84)
  #00  pc 00000000009d8fc1  /system/framework/arm/boot-framework.oat (offset 0x3ef000) (android.opengl.GLSurfaceView$GLThread.guardedRun+3040)
  #00  pc 00000000009d9e05  /system/framework/arm/boot-framework.oat (offset 0x3ef000) (android.opengl.GLSurfaceView$GLThread.run+180)
  #00  pc 0000000000420f75  /system/lib/libart.so (art_quick_invoke_stub_internal+68)
  #00  pc 00000000003fa349  /system/lib/libart.so (art_quick_invoke_stub+224)
  #00  pc 00000000000a4709  /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+136)
  #00  pc 0000000000357e9d  /system/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+52)
  #00  pc 0000000000358bf5  /system/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+320)
  #00  pc 000000000037a123  /system/lib/libart.so (art::Thread::CreateCallback(void*)+866)
  #00  pc 0000000000064905  /system/lib/libc.so (__pthread_start(void*)+22)
  #00  pc 000000000001e841  /system/lib/libc.so (__start_thread+24)
```


Again, I was unable to reproduce them on my own, but users complain every day.