[TIMOB-23938] Android: Titanium crashes if back button is hit soon enough after app launch
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-10-06T12:14:30.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.0.0 |
Components | Android |
Labels | alloy, android, crash, qe-6.0.0 |
Reporter | Ygor Lemos |
Assignee | Gary Mathews |
Created | 2016-09-21T22:05:40.000+0000 |
Updated | 2017-10-13T02:23:12.000+0000 |
Description
Based on http://developer.appcelerator.com/question/180283/always-a-crash-race-condition-with-android-back-button
Summary - If you press back fast enough during app open Titanium apps will crash. Looks like the android back event that causes the app to tear down can cause the root UI element to be null when adding the first Window of the project to it.
This happens on device for the bare minimum installs of Titanium project with or without Alloy. Easier to repro on Alloy as it takes a bit longer for the app to launch.
TI 3.5.0.GA
Mac Yosemite
Samsung Galaxy S5 and Note3 (and others)
1. ti create a new android project
2. cd into root of project
3. alloy create
4. ti build -p android -T device --device-id
5. Important step: On the device (not simulator), launch app AND IMMEDIATELY start pressing back button.
** Keep closing and reopening app as fast as you can if you don't see it repro the first time in step 5
**** This happens when a Window is the default/first item created in the Activity as well
Expected -
App closes
Actual -
App crashes and closes
Stack -
01-27 13:32:08.269: E/AndroidRuntime(20104): FATAL EXCEPTION: main
01-27 13:32:08.269: E/AndroidRuntime(20104): Process: com.test, PID: 20104
01-27 13:32:08.269: E/AndroidRuntime(20104): java.lang.NullPointerException
01-27 13:32:08.269: E/AndroidRuntime(20104): at android.content.ComponentName.(ComponentName.java:77)
01-27 13:32:08.269: E/AndroidRuntime(20104): at android.content.Intent.(Intent.java:4445)
01-27 13:32:08.269: E/AndroidRuntime(20104): at ti.modules.titanium.ui.WindowProxy.handleOpen(WindowProxy.java:127)
01-27 13:32:08.269: E/AndroidRuntime(20104): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:88)
01-27 13:32:08.269: E/AndroidRuntime(20104): at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:415)
01-27 13:32:08.269: E/AndroidRuntime(20104): at android.os.Handler.dispatchMessage(Handler.java:98)
01-27 13:32:08.269: E/AndroidRuntime(20104): at android.os.Looper.loop(Looper.java:146)
01-27 13:32:08.269: E/AndroidRuntime(20104): at android.app.ActivityThread.main(ActivityThread.java:5678)
01-27 13:32:08.269: E/AndroidRuntime(20104): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 13:32:08.269: E/AndroidRuntime(20104): at java.lang.reflect.Method.invoke(Method.java:515)
01-27 13:32:08.269: E/AndroidRuntime(20104): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
01-27 13:32:08.269: E/AndroidRuntime(20104): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
01-27 13:32:08.269: E/AndroidRuntime(20104): at dalvik.system.NativeStart.main(Native Method)
We are getting a lot of this error on Appcelerator APM (Crittercism) on our app running on versions built both with Ti 5.5.0.GA as with Ti 5.3.0.GA
As a workaround, try using empty window which would listen to "androidback" event, in which app would be put in background (launch intent with "home" category).
Resolved by: https://github.com/appcelerator/titanium_mobile/pull/8465
Verified as fixed, the application no longer crashes when the back button is hit quickly after app launch. Tested On: {noformat} Nexus 6p (7.0) Nexus 5X 6.0.1 Mac OSX Sierra 10.12 Ti SDK: 6.0.0.v20161006080234 Appc Studio: 4.8.0.201609292239 Appc NPM: 4.2.8-7 App CLI: 6.0.0-56 Node v4.4.7 {noformat} *Closing ticket.*
Hi can you back port it to SDK 5.5.1? thanks