Debugging strange Android-only crash

I’ve got a game that’s crashing seemingly randomly. The process just seems to be killed – no signal or anything is sent that I can debug. This is what I see in adb logcat:

02-02 13:58:59.902 946-1611/system_process I/WindowState: WIN DEATH: Window{42418d88 u0 SurfaceView}
02-02 13:58:59.902 946-1604/system_process I/ActivityManager: Process my.game.bundle (pid 9723) has died.
02-02 13:58:59.912 946-1604/system_process W/ActivityManager: Force removing ActivityRecord{42370f90 u0 my.game.bundle/.AppActivity t15}: app died, no saved state
02-02 13:58:59.913 946-1557/system_process I/WindowState: WIN DEATH: Window{423b8698 u0 my.game.bundle/my.game.bundle.AppActivity}

I have no idea where to begin debugging as the game itself doesn’t appear to do anything wrong. It just gets killed. This leads me to believe it may be a memory issue? I’ve found that the crash seems way easier to reproduce on an older CyanogenMod ROM, but not on newer LineageOS ROMs. Any tips as to where to look to see why the process is being killed?

Does it crash on all Android devices you’ve tried or just some Android devices?

EDIT: I see you’ve mentioned older CyanogenMod ROMs and LineageOS ROMs. What are you doing to reproduce the crash? does it happen in the same use case every time? You could try and monitor logcat with

adb logcat | grep -i "`adb shell ps | grep com.package.name | cut -c11-15`"

what about to try debug with: Cocos2d-x Android Studio NDK build C++ DEBUG - WORKS!

It only seems to crash on some devices. It’s not predictable – definitely not at the same point each time. Native debugging is already enabled and working. As I mentioned, though, no nasty signals or anything (such as SIGSEGV) arrive in the native code. The application just “dies” according to logcat, but for no reason. That’s why I’m thinking it’s memory-related.

what about adding crashlytics to see if something more can be gathered?

I can certainly try that. I guess the problem is that I don’t think it’s even technically a “crash”. I think the Android OS is just killing the app, because there’s no output in logcat showing an exception in the Java layer and the debugger doesn’t stop on any kind of signal. The app just shuts off.

Are u compiling in debug or release mode? SO add crashlytics with ndk support - dont forget to run upload symobls to get more input

I was able to get it to crash in a debug build with the debugger attached – but again, nothing actually shows up in the debugger. The app just closes and the only evidence that something went wrong is that adb logcat shows that the process “died” (which is apparently common in low-memory situations?).

xmm are u sure that u not missing any other output - maybe have a try to post there bigger log from start of the app until crash. I think sometimes in such way app crashing due google play services or some CCAction.

Yep – quite sure that that’s all the logcat output there is. A few lines earlier are debug output lines just saying things are running as normal. And then the process just dies! Other processes are dying also. For instance, this is immediately before my app dies:

02-02 13:58:59.211 275-495/? I/QCOM PowerHAL: Processing audio hint. Metadata: state=0
02-02 13:58:59.279 946-1557/system_process I/ActivityManager: Process com.android.inputmethod.latin (pid 9504) has died.
02-02 13:58:59.281 946-1557/system_process W/ActivityManager: Scheduling restart of crashed service com.android.inputmethod.latin/.LatinIME in 1000ms
02-02 13:58:59.282 946-946/system_process W/InputMethodManagerService: Session failed to close due to remote exception
                                                                       android.os.DeadObjectException
                                                                           at android.os.BinderProxy.transact(Native Method)
                                                                           at com.android.internal.view.IInputMethodSession$Stub$Proxy.finishSession(IInputMethodSession.java:292)
                                                                           at com.android.server.InputMethodManagerService.finishSessionLocked(InputMethodManagerService.java:1373)
                                                                           at com.android.server.InputMethodManagerService.clearClientSessionLocked(InputMethodManagerService.java:1364)
                                                                           at com.android.server.InputMethodManagerService.clearCurMethodLocked(InputMethodManagerService.java:1390)
                                                                           at com.android.server.InputMethodManagerService.onServiceDisconnected(InputMethodManagerService.java:1409)
                                                                           at android.app.LoadedApk$ServiceDispatcher.doDeath(LoadedApk.java:1113)
                                                                           at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1127)
                                                                           at android.os.Handler.handleCallback(Handler.java:733)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                           at android.os.Looper.loop(Looper.java:136)
                                                                           at com.android.server.ServerThread.initAndLoop(SystemServer.java:1299)
                                                                           at com.android.server.SystemServer.main(SystemServer.java:1396)
                                                                           at java.lang.reflect.Method.invokeNative(Native Method)
                                                                           at java.lang.reflect.Method.invoke(Method.java:515)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
                                                                           at dalvik.system.NativeStart.main(Native Method)

This implies that the Android process for the keyboard itself also dies.