Skip to content

Commit

Permalink
fix(android): softRestart() must account for snapshots (#11338)
Browse files Browse the repository at this point in the history
maintain and rename global snapshot method

Fixes TIMOB-27602
  • Loading branch information
garymathews authored and sgtcoolguy committed Nov 15, 2019
1 parent 38ea44b commit 62a603d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,15 @@ public void softRestart()
runtime.initRuntime();

// manually re-launch app
runtime.doRunModuleBytes(KrollAssetHelper.readAssetBytes(appPath), appPath, rootActivity.getActivityProxy());
if (KrollAssetHelper.assetExists(appPath)) {
runtime.doRunModuleBytes(KrollAssetHelper.readAssetBytes(appPath), appPath,
rootActivity.getActivityProxy());

// launch script does not exist, must be using snapshot
// execute startup method baked in snapshot
} else {
runtime.doRunModule("global._startSnapshot(global)", appPath, rootActivity.getActivityProxy());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected void loadScript()
// launch script does not exist, must be using snapshot
// execute startup method baked in snapshot
} else {
KrollRuntime.getInstance().runModule("global.startSnapshot(global)", fullUrl, activityProxy);
KrollRuntime.getInstance().runModule("global._startSnapshot(global)", fullUrl, activityProxy);
}
} finally {
Log.d(TAG, "Signal JS loaded", Log.DEBUG_MODE);
Expand Down
3 changes: 1 addition & 2 deletions build/lib/android/startup.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
this.startSnapshot = function (global) {
delete global.startSnapshot;
this._startSnapshot = function (global) {
<%- script %>
}

0 comments on commit 62a603d

Please sign in to comment.