Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26774

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


    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 7.5.0
    • Fix Version/s: Release 7.5.1
    • Component/s: Android
    • Environment:
    • Story Points:
    • Sprint:
      2019 Sprint 4


      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.

      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.

      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:

      1. Create a classic Titanium app.
      2. Set project name to "IntentTest". (This is <name/> in "tiapp.xml".)
      3. Set project's "Application Id" to "com.appc.intent.test". (This is <id/> in "tiapp.xml.)
      4. Set up the "app.js" with the below code.
      5. Build and run on Android.
      6. Wait for the app to launch.
      7. Open the Mac "Terminal" app.
      8. CD (change directory) to: ~/Library/Android/sdk/platform-tools
      9. 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);
      	text: text,
      	width: Ti.UI.FILL,
      	height: Ti.UI.SIZE,

      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


          Issue Links



              • Assignee:
                jquick Joshua Quick
                rislam Riduanul Islam
                Gary Mathews
                Samir Mohammed
              • Watchers:
                5 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    Sync status:
                    Last received:
                    Last sent:

                    Git Integration