Skip to content

Commit

Permalink
Fix Worker script path undefined on Android
Browse files Browse the repository at this point in the history
Due to a difference in execution order in Android & iOS cordova code
the workerScriptPath was already deleted on Android when the script was
supposed to load.

Change-Id: I5c12cd7abd4c4dfb9645a01c9dd98e24b465e54f
  • Loading branch information
tbuschto committed Oct 4, 2021
1 parent 1368919 commit 915d08e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/boot/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ tabris._start = function(client) {
const cordovaScript = document.createElement('script');
cordovaScript.src = './cordova.js';
document.head.appendChild(cordovaScript);
const isWorker = global.workerScriptPath !== undefined;
const workerScriptPath = global.workerScriptPath;
delete global.workerScriptPath;
const isWorker = workerScriptPath !== undefined;
if (tabris._init) {
tabris._init(client, {headless: isWorker});
}
Expand All @@ -36,7 +38,7 @@ tabris._start = function(client) {
if (global.debugClient && !isWorker) {
global.debugClient.start(rootModule);
}
rootModule.require('./' + (isWorker ? global.workerScriptPath : ''));
rootModule.require('./' + (isWorker ? workerScriptPath : ''));
tabris.flush();
} catch (error) {
printError('Could not load ' + (isWorker ? 'worker' : 'main module') + ':', error);
Expand All @@ -48,7 +50,6 @@ tabris._start = function(client) {
} else {
loadModule();
}
delete global.workerScriptPath;
tabris.flush();
} catch (error) {
printError('Could not start tabris:', error);
Expand Down

0 comments on commit 915d08e

Please sign in to comment.