Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26914] Android: An OS forced-quit app displays a blank window upon relaunch as of 8.0.0

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-04-29T15:06:34.000+0000
Affected Version/sRelease 8.0.0
Fix Version/sRelease 8.0.1
ComponentsAndroid
Labelsandroid, engSchedule, freeze, regression, restart
ReporterMichael Gangolf
AssigneeJoshua Quick
Created2019-03-16T14:29:35.000+0000
Updated2019-04-29T18:29:05.000+0000

Description

*Summary:* If the OS force-quits the app (such as due to low memory), then when you relaunch the app later, it'll show a blank window as of Titanium 8.0.0. This is not an issue if the end-user force-quits the app. This is not an issue when the app is launched via a data intent such as URL scheme or notification. This was not an issue before Titanium 8.0.0 _(the old code would schedule an app restart)_. *Steps to reproduce:*

On Android, go to its "Developer Options" screen.

Tap on the "Background process limit" row. _(It's near the bottom of the list.)_

Tap on "No background processes". _(This tells the OS to force quit the last displayed app when launching another app.)_

Create a "Classic" default Titanium project.

Build and run on the same Android device configured above.

Wait for the app to launch.

Tap on the Android "Home" button.

Launch a different app such as "Gmail".

Tap on the Android "Home" button.

Resume the Titanium app.

*Result:* When resuming/relaunching the app, a blank window is displayed. *Expected Result:* Since the app was forced-quit by the OS, the app should restart normally, starting with the splash screen. *Note:* When the Android OS force-quits the app, next time you relaunch it with the same intent, the OS will attempt to restore it back to its previous state starting with its top-most child activity. The OS will recreate the activities in reverse order, starting with the last displayed top-most child activity and ending with the root activity. The OS won't attempt to restore/recreate the parent activity until you close/finish/destroy the child activity. The OS won't perform the above restore behavior if the end-user force-quits the app. _(Ticket description was rewritten now that issue has been isolated.)_

Attachments

FileDateSize
test_restart.zip2019-03-16T14:28:12.000+00003397832
ti_log2.txt2019-03-16T14:27:33.000+00003077

Comments

  1. Sharif AbuDarda 2019-03-17

    Hello, I have tested your sample app in Android 9 device. I followed your step of backgrounding the app and remain until the process stops and shown in the log. Now, going back to the backgrounded app and opening it, I see no black screen, just the white window I suppose to see. Is the issue is only with Android 7 device? Can you try with a different version of Android? Thanks.
  2. Joshua Quick 2019-03-19

    I can reproduce this issue if I set Android's "Background process limit" to 1 under "Developer Options". The issue does not happen if the app has a service running.
  3. Joshua Quick 2019-03-20

    -PR (master): https:// github.com/appcelerator/titanium_mobile/pull/10787- -PR (8.0.x): https:// github.com/appcelerator/titanium_mobile/pull/10790- *_Edit:_* _Closing the above PRs since it'll still display a blank window when system developer option "Don't keep activities" is enabled. My PRs below is the better solution._
  4. Rainer Schleevoigt 2019-03-31

    In my app a foreground service with notification will started and the issue with gray screen happens nevertheless.
  5. Joshua Quick 2019-04-12

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10829
  6. Joshua Quick 2019-04-26

    PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10868
  7. Lokesh Choudhary 2019-04-26

    FR passed PR merged.
  8. Rainer Schleevoigt 2019-04-27

    Where I can download? http://builds.appcelerator.com/#8_0_X ?
  9. Rainer Schleevoigt 2019-04-27

    I will test this mobilesdk-8.0.1.v20190426162041-osx.zip .
  10. Rainer Schleevoigt 2019-04-27

    OK other behavior: Instead of splash screen I shorty see the gray screen. If I switch to "don't keep activities" the I can commit that the bug is partly fixed: First test: 1. running app 2. home 3. start again => OK (over gray splash screen ) Second test: 1. running app 2. screen of 3. screen on => restart app with last screen EDIT: was my failure, seems to work and the intro seems to be a little faster
  11. Samir Mohammed 2019-04-29

    Closing ticket, fix verified in SDK version 8.0.1.v20190426162041 and SDK version 8.1.0.v20190426222341. Test and other information can be found at: Master : https://github.com/appcelerator/titanium_mobile/pull/10829 8_0_X: https://github.com/appcelerator/titanium_mobile/pull/10868
  12. Joshua Quick 2019-04-29

    Thanks for testing it out [~titanium@webmasterei-hamburg.de]. And you will see a gray screen on relaunch for a brief moment if you set system developer option "Background process limit" to "None", launch the app, launch a different app, and then relaunch your app. The reason is because the Android OS forced quit the app in the background and upon relaunch it attempts to launch via the last displayed child activity (in Titanium's case the "TiActivity") instead of the main activity. There's nothing we can really do about this and other apps will show this behavior as well, including Google's own apps. Our solution for Titanium 8.1.0 is to improve the app's cold start up time, which we've already done on the "master" branch. It now starts up 2-4 times faster depending the device.
  13. Michael Gangolf 2019-04-29

    And you can set an image for TiActivity (e.g. the logo, a "app is loading...",...) with <activity android:name="org.appcelerator.titanium.TiActivity" android:theme="@style/Theme.Custom.Splash"/> in the application part of your tiapp.xml and set an image in the theme
        <style name="Theme.Custom.Splash" parent="@style/Theme.Titanium">
        		<item name="android:windowBackground">@drawable/background_cropped</item>
        </style>
        
    Looks way better than just a grey screen.
  14. Joshua Quick 2019-04-29

    What [~michael] will work. Just note that it changes the default background for all Ti.UI.Window objects to use that image. You can get around that by applying your own background image or color to your child windows.

JSON Source