Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20108] App sometimes crashes on resume

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-12-08T02:53:07.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.2.0
ComponentsAndroid
Labelsandroid, crash
ReporterCollin Price
AssigneeAshraf Abu
Created2015-12-03T21:49:33.000+0000
Updated2016-02-05T00:15:35.000+0000

Description

We have found that *sometimes* on the Android platform when a user resumes out app it crashes immediately. To the user it looks like they click on the app icon and there is a black flash and they have to click the app icon again to launch it. I have attached a log from Critterism. From our testing and the logs it looks like it occurs when the app is backgrounded for a couple hours. After investigating the crash log it looks like the crash occurs in the "TiBaseActivity" class. The method "callOrientationChangedListener" is passed a null Activity object and the method fails to check for null before calling "activity.getWindowManager()". The null activity is coming from TiApplication.getAppRootOrCurrentActivity(). I have not been able to determine a case there TiApplication.getAppRootOrCurrentActivity() should ever return null.

Attachments

FileDateSize
crash.log2015-12-03T21:45:40.000+000011332

Comments

  1. Collin Price 2015-12-03

    I have tested the SDK using a build that checks for null before performing the action in the callOrientationChangedListener method and this appears to have fixed the issue. This issue is hard to reproduce though. [PR](https://github.com/appcelerator/titanium_mobile/pull/7543) sent.
  2. Ashraf Abu 2015-12-04

    [~CollinPrice] Thanks for the fix. How exactly do I reproduce or test this crash out?
  3. Collin Price 2015-12-04

    One problem we have is that we cannot reliably recreate the crash. We have rarely seen the crash occur in person but we can see the stack trace from the crash logs in Critterism. If you actually look in TiBaseActivity class you can see that its crashing in a place that is abstracted away in the Titanium SDK. Anyone using a Window object on Android might get this type of crash too.
  4. Ashraf Abu 2015-12-08

    [~CollinPrice] We can probably get this reviewed and merged.
  5. Ashraf Abu 2015-12-08

    The code changes are in the callOrientationChangedListener method. To ensure no regressions, test with this:-
       var win = Ti.UI.createWindow({
       });
       
       win.open();
       
       Ti.Gesture.addEventListener('orientationchange', function (event) {
       
           Ti.API.info('orientationchanged!');
       
       });
       
    and this:-
       var win = Ti.UI.createWindow({
       });
       
       win.open();
       
    Rotate the devices and ensure no crashes.
  6. Ashraf Abu 2015-12-08

    PR merged.
  7. Collin Price 2015-12-08

    Thanks for accepting the PR. I know this was a weird one.
  8. Ashraf Abu 2015-12-09

    (y)
  9. Lokesh Choudhary 2016-02-05

    Verified the fix. Kept the app in the background for 2 hrs & then resumed it, no crash seen. Closing. Environment: Appc Studio : 4.5.0.201601262138 Ti SDK : 5.2.0.v20160204140025 Ti CLI : 5.0.6 Alloy : 1.7.33 MAC Yosemite : 10.10.5 Appc NPM : 4.2.3-2 Appc CLI : 5.2.0-242 Node: 4.2.2 Nexus 6P - Android 6.0

JSON Source