Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26774] Android: When backgrounded, data intent no longer re-executes "app.js" as of 7.5.0

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2019-02-12T18:37:15.000+0000
Affected Version/sRelease 7.5.0
Fix Version/sRelease 7.5.1
ComponentsAndroid
LabelsEscalation, android, intent, regression
ReporterRiduanul Islam
AssigneeJoshua Quick
Created2019-01-28T20:28:55.000+0000
Updated2019-02-22T10:25:47.000+0000

Description

*Summary:* If the Android app's UI is in the background and you attempt to launch it via a data intent (aka: URL scheme, notification, or startActivity() intent), then the app's splash screen will be displayed but nothing will happen. This is a *regression* as of 7.5.0. Titanium 7.4.2 and older versions would re-execute the "app.js" in this case. *Cause:* What's happening is that a new UI activity stack is being created by the data intent while an existing UI stack already exists in the background. Titanium only supports running 1 JavaScript runtime at a time (does not support multiple JS runtimes). So, when the 2nd UI stack is displayed, it attempts to load the "app.js" when it was already loaded before. In Titanium 7.4.2 and older versions, Titanium would re-execute the "app.js" for the JavaScript runtime, even though it was already loaded before. This was unintended behavior, but some app developers depend on this behavior. As of 7.5.0, Titanium now loads a "ti.main.js" script on startup (our bootstrap script) and then loads the "app.js" via the require() function. But for the 2nd UI stack, since it's re-using an existing JavaScript runtime and the "app.js" was loaded before, the require() function won't re-execute the script and returns a cached module instead. This behavior is technically correct, but the old unexpected behavior is what's desired for Titanium 7.5.x. *Note:* As of Titanium 8.0.0, the above is not an issue. Intent handling was refactored in 8.0.0 to guarantee that only one UI stack exists at a time. Data intents will instead resume the existing UI stack like how iOS works. See [TIMOB-26075] for more details. *Steps to reproduce:*

Create a classic Titanium app.

Set project name to "IntentTest". (This is <name/> in "tiapp.xml".)

Set project's "Application Id" to "com.appc.intent.test". (This is <id/> in "tiapp.xml.)

Set up the "app.js" with the below code.

Build and run on Android.

Wait for the app to launch.

Open the Mac "Terminal" app.

CD (change directory) to: ~/Library/Android/sdk/platform-tools

In the terminal, enter: ./adb shell am start -n com.appc.intent.test/.IntenttestActivity -a android.intent.action.VIEW -d https://www.google.com -f 0x04000000

var window = Ti.UI.createWindow();
var text = "Hello World!";
if (Ti.Android) {
	text += "\n\nLaunch Intent:\n" + JSON.stringify(Ti.Android.currentActivity.intent);
}
window.add(Ti.UI.createLabel({
	text: text,
	width: Ti.UI.FILL,
	height: Ti.UI.SIZE,
}));
window.open();
*Result:* A new splash screen window instance is displayed, but doesn't show the window and label implemented via the "app.js" code. *Expected Result:* It should re-execute the "app.js" when 2nd UI stack is displayed to maintain old behavior. ---- *Original Description* ---- Using 7.5.0.GA, application gets stuck on the splash screen when navigating back from the TargetApp towards the SourceApp after having the TargetApp opened from the SourceApp. Using 7.4.2.GA, it was working fine. If you make 2 apps use the code below and tap their buttons to launch the other app, you can reproduce this behavior. [^SourceApp.js] [^TargetApp.js]

Attachments

FileDateSize
SourceApp.js2019-02-06T01:50:58.000+0000663
TargetApp.js2019-02-06T01:50:59.000+0000578

Comments

  1. Joshua Quick 2019-02-06

    PR (7.5.x): https://github.com/appcelerator/titanium_mobile/pull/10678
  2. Samir Mohammed 2019-02-11

    FR Passed. Awaiting on CR before merge.
  3. Samir Mohammed 2019-02-22

    *Closing ticket* Fix verified in SDK Version 7.5.1.v20190219102458. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/10678

JSON Source