[TIMOB-26914] Android: An OS forced-quit app displays a blank window upon relaunch as of 8.0.0
GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-04-29T15:06:34.000+0000 |
Affected Version/s | Release 8.0.0 |
Fix Version/s | Release 8.0.1 |
Components | Android |
Labels | android, engSchedule, freeze, regression, restart |
Reporter | Michael Gangolf |
Assignee | Joshua Quick |
Created | 2019-03-16T14:29:35.000+0000 |
Updated | 2019-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
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.
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.-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._
In my app a foreground service with notification will started and the issue with gray screen happens nevertheless.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10829
PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10868
FR passed PR merged.
Where I can download? http://builds.appcelerator.com/#8_0_X ?
I will test this mobilesdk-8.0.1.v20190426162041-osx.zip .
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
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
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.
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 themeLooks way better than just a grey screen.
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.