Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27904] Android: Incremental build duplicates "bootstrap.json" entries as of 8.1.0

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2020-06-08T14:05:41.000+0000
Affected Version/sRelease 8.1.0
Fix Version/sRelease 9.0.3
ComponentsAndroid
Labelsandroid, bootstrap, build, incremental, regression
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-05-21T20:24:46.000+0000
Updated2020-06-08T14:05:41.000+0000

Description

*Summary:* If a project contains a JS file ending with *.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.

Comments

  1. Joshua Quick 2020-05-21

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11727
  2. Satyam Sekhri 2020-05-26

    FR Passed. Waiting for Jenkins build
  3. Joshua Quick 2020-06-02

    PR (9.0.x): https://github.com/appcelerator/titanium_mobile/pull/11745
  4. Ewan Harris 2020-06-08

    Verified changes in 9.0.3.v20200608051820 and 9.1.0.v20200604104832. Closing ticket.

JSON Source