We are getting a crash whenever user changes device language & if game is in background. we are using cocos2dJs3.17.1 to build our games. It seems it is framework issue because to test this scenario we created new blank project & tried the same thing, it crashed.
Steps to produce the crash :
game will crash once you click any button.
Stack trace from adb logcat:
01-31 12:10:57.814 6212 6451 W cr_ChildProcessConn: onServiceDisconnected (crash or killed by oom): pid=6454
01-31 12:10:57.998 6212 6212 E chromium: [ERROR:aw_browser_terminator.cc(125)] Renderer process (6454) crash detected (code -1).
01-31 12:10:58.026 6212 6212 E chromium: [ERROR:aw_browser_terminator.cc(90)] Render process (6454) kill (OOM or update) wasn't handed by all associated webviews, killing application.
01-31 12:10:58.183 3544 3544 I Zygote : Process 6212 exited due to signal (9)
01-31 12:10:58.201 3926 4301 I ActivityManager: Process com.x.x (pid 6212) has died: cch+1CAC (117,340)"
Any idea or solution please do share in this thread.
It would be better to manually restart the app in those cases. You can change the main activity slightly as follows:
private final String TRIGGER_REBIRTH = "trigger_rebirth";
@Override
protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null) {
if (savedInstanceState.getBoolean(TRIGGER_REBIRTH, false)) {
// Trigger app restart here
// See Implementation - https://github.com/JakeWharton/ProcessPhoenix
ProcessPhoenix.triggerRebirth(this, getIntent());
}
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putBoolean(TRIGGER_REBIRTH, true);
}
Also prevents the Cocos2d-x JS engine crash, JS_AbortIfWrongThread which happens after user navigates to app which was killed by android while in background.