[TIMOB-27904] Android: Incremental build duplicates "bootstrap.json" entries as of 8.1.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-06-08T14:05:41.000+0000 |
Affected Version/s | Release 8.1.0 |
Fix Version/s | Release 9.0.3 |
Components | Android |
Labels | android, bootstrap, build, incremental, regression |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-05-21T20:24:46.000+0000 |
Updated | 2020-06-08T14:05:41.000+0000 |
Description
*Summary:*
If a project contains a JS file ending with Copy the below
*.bootstrap.js
, then every Android incremental build performed will duplicate its entry within our ti.internal/bootstrap.json
file. This causes the bootstrap JS file to be executed multiple times on startup.
This regression was introduced in Titanium 8.1.0.
*Note:*
This only negatively impacts bootstraps that have an execute()
function such as [ti.playservices](https://github.com/appcelerator-modules/ti.playservices/blob/master/android/Resources/ti.playservices/ti.playservices.bootstrap.js), because that function will end up being invoked multiple times.
*Steps to reproduce:*
Create a Titanium app project.
Copy the below test.bootstrap.js
to the Resources
directory.
Build and run on Android.
Notice a bootstrap dialog appears once. _(This is good.)_
Build and run on Android again.
Notice *two* bootstrap dialogs appear on startup. _(This is bad.)_
Build and run on Android again.
Notice *three* bootstrap dialogs appear on startup. _(This is bad.)_
\\./Resources/test.bootstrap.js
Ti.API.info("### Bootstrap was required-in.");
var wasExecuted = false;
exports.execute = function(finished) {
Ti.API.info("### Bootstrap execute() method was called.");
var message = "This is the bootstrap dialog.";
if (wasExecuted) {
message = "Uh-oh!!! Bootstrap was wrongly executed again.";
}
var dialog = Ti.UI.createAlertDialog({
message: message,
buttonNames: ['OK'],
cancel: 0,
persistent: true,
});
dialog.addEventListener('click', finished);
dialog.addEventListener('cancel', finished);
dialog.show();
wasExecuted = true;
};
*Cause:*
The incremental build changes made in Titanium 8.1.0 by [TIMOB-27043] moved bootstrap script finding code to our core [process-js-task.js](https://github.com/appcelerator/titanium_mobile/blob/master/cli/lib/tasks/process-js-task.js) file. The iOS _build.js
was changed to not fetch bootstrap scripts itself anymore... but the same as not done in Android's _build.js
which is why the entries are being duplicated.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/11727
FR Passed. Waiting for Jenkins build
PR (9.0.x): https://github.com/appcelerator/titanium_mobile/pull/11745
Verified changes in 9.0.3.v20200608051820 and 9.1.0.v20200604104832. Closing ticket.