Crash on device during language change in cocos2dJs cross platform game (in Android Platform)

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 :

  1. Open the game.
  2. Go to device settings & change the language.
  3. Open the background game (that is there in background )
  4. Click some buttons in game ( you should have some button that have some touch events )

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.

Answers:

Answer

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.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.