[TIMOB-20108] App sometimes crashes on resume
GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-12-08T02:53:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.2.0 |
Components | Android |
Labels | android, crash |
Reporter | Collin Price |
Assignee | Ashraf Abu |
Created | 2015-12-03T21:49:33.000+0000 |
Updated | 2016-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
File | Date | Size |
crash.log | 2015-12-03T21:45:40.000+0000 | 11332 |
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.
[~CollinPrice] Thanks for the fix. How exactly do I reproduce or test this crash out?
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.
[~CollinPrice] We can probably get this reviewed and merged.
The code changes are in the
callOrientationChangedListener
method. To ensure no regressions, test with this:-and this:-
Rotate the devices and ensure no crashes.
PR merged.
Thanks for accepting the PR. I know this was a weird one.
(y)
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