Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18464] Android: Titanium crashes if back button is hit soon enough after app launch

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-03-11T07:25:44.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.1.0
ComponentsAndroid
Labelsalloy, android, crash
Reporterjosh rose
AssigneeHieu Pham
Created2015-01-27T21:39:30.000+0000
Updated2016-09-21T22:05:41.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)

Comments

  1. josh rose 2015-02-09

    @ingo do you need anything from me? It's an easy repro and can crash basically any app (unless you have a workaround?)
  2. Ingo Muschenetz 2015-02-09

    [~wpccolorblind] not yet, but we will let you know.
  3. Hieu Pham 2015-03-10

    master PR: https://github.com/appcelerator/titanium_mobile/pull/6706
  4. Jason Priebe 2015-04-09

    I have found that a similar crash happens if the app is busy building a new view when you hit the back button to exit the app. I hope the PR addresses that situation, too.
  5. Lokesh Choudhary 2015-06-09

    Verified the fix. App does not crash anymore. Closing. Environment: Appc Studio : 4.1.0.201505071004 Ti SDK : 4.1.0.v20150605164428 Ti CLI : 4.0.1 Alloy : 1.6.0 MAC Yosemite : 10.10.3 Appc npm : 4.0.0 Appc CLI : 4.0.2-rc2 Node: v0.10.37 Device - Android 5.0.1
  6. Muhammad Ahmed Fahad 2015-06-22

    Problem still seems to persist in build: *4.1.0.v20150619182147* Trying on a Physical device (OnePlus One)
  7. Zishan Khan 2015-08-19

    This problem still exists on 4.1.0. Tested on Nexus 6, S3 & S4. Please re-open and review.
  8. Ghassan 2015-08-19

    ditto
  9. ardy wongso 2015-08-26

    The problem still exist on 4.1.0 Tested on samsung S5 [ERROR] : TiApplication: (main) [2,487] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.removeAllViews()' on a null object reference; Titanium 4.1.0,2015/07/06 11:15,d57aa7d[ERROR] : TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.removeAllViews()' on a null object reference [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIActivityIndicator.setStyle(TiUIActivityIndicator.java:164) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIActivityIndicator.processProperties(TiUIActivityIndicator.java:86) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1209) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:501) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:492) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:470) [ERROR] : TiApplication: at ti.modules.titanium.ui.ActivityIndicatorProxy.handleHide(ActivityIndicatorProxy.java:94) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:258) [ERROR] : TiApplication: at ti.modules.titanium.ui.ActivityIndicatorProxy.handleMessage(ActivityIndicatorProxy.java:67) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:145) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5832) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) [ERROR] : AndroidRuntime: FATAL EXCEPTION: main [ERROR] : AndroidRuntime: Process: com.test.test, PID: 12323 [ERROR] : AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.removeAllViews()' on a null object reference [ERROR] : AndroidRuntime: at ti.modules.titanium.ui.widget.TiUIActivityIndicator.setStyle(TiUIActivityIndicator.java:164) [ERROR] : AndroidRuntime: at ti.modules.titanium.ui.widget.TiUIActivityIndicator.processProperties(TiUIActivityIndicator.java:86) [ERROR] : AndroidRuntime: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1209) [ERROR] : AndroidRuntime: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:501) [ERROR] : AndroidRuntime: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:492) [ERROR] : AndroidRuntime: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:470) [ERROR] : AndroidRuntime: at ti.modules.titanium.ui.ActivityIndicatorProxy.handleHide(ActivityIndicatorProxy.java:94) [ERROR] : AndroidRuntime: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:258) [ERROR] : AndroidRuntime: at ti.modules.titanium.ui.ActivityIndicatorProxy.handleMessage(ActivityIndicatorProxy.java:67) [ERROR] : AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : AndroidRuntime: at android.os.Looper.loop(Looper.java:145) [ERROR] : AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5832) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
  10. Caio Perdona 2016-09-21

    Guys, it is still happening on 5.5.0.GA. When I press back button on android while splash screen is active, I get this crash. Android 5 and 6.
  11. Ygor Lemos 2016-09-21

    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

JSON Source