[TIMOB-26774] Android: When backgrounded, data intent no longer re-executes "app.js" as of 7.5.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-02-12T18:37:15.000+0000 |
Affected Version/s | Release 7.5.0 |
Fix Version/s | Release 7.5.1 |
Components | Android |
Labels | Escalation, android, intent, regression |
Reporter | Riduanul Islam |
Assignee | Joshua Quick |
Created | 2019-01-28T20:28:55.000+0000 |
Updated | 2019-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 Set project name to "IntentTest". (This is
Set project's "Application Id" to "com.appc.intent.test". (This is
CD (change directory) to:
In the terminal, enter:
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
File | Date | Size |
---|---|---|
SourceApp.js | 2019-02-06T01:50:58.000+0000 | 663 |
TargetApp.js | 2019-02-06T01:50:59.000+0000 | 578 |
PR (7.5.x): https://github.com/appcelerator/titanium_mobile/pull/10678
FR Passed. Awaiting on CR before merge.
*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