Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26027] Android: Analytics can cause a crash on Android 8 if app is backgrounded

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2018-06-05T16:09:21.000+0000
Affected Version/sRelease 7.1.1
Fix Version/sRelease 7.2.0
ComponentsAndroid
Labelsn/a
ReporterHans Knöchel
AssigneeGary Mathews
Created2018-05-09T15:26:24.000+0000
Updated2018-06-05T22:37:59.000+0000

Description

When using Analytics (enabled by default via the tiapp.xml property <analytics>true</analytics, an Android app can randomly crash:
java.lang.IllegalStateException: 

at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1538)
at android.app.ContextImpl.startService (ContextImpl.java:1484)
at android.content.ContextWrapper.startService (ContextWrapper.java:663)
at com.appcelerator.aps.APSAnalyticsHelper$AnalyticsCallback.handleMessage (APSAnalyticsHelper.java:540)
at android.os.Handler.dispatchMessage (Handler.java:101)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6938)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
The crash happens in the "handleMessage" method of the "APSAnalyticsHelper.java" and indicates an issue with the main thread. We removed the class recently, as part of [this PR](https://github.com/appcelerator/aps_sdk/pull/312), so it might not be an issue in future versions of the SDK. [~iwhitfield] to confirm

Comments

  1. Gary Mathews 2018-05-09

    aps_sdk: https://github.com/appcelerator/aps_sdk/pull/315
  2. Gary Mathews 2018-05-09

    titanium_mobile: https://github.com/appcelerator/titanium_mobile/pull/10008
  3. Gary Mathews 2018-05-22

    Updated APSAnalytics in this PR: https://github.com/appcelerator/aps_sdk/pull/317/commits/7251b20b3eab3b011cffefa93dda24768ad3adc5
  4. Lokesh Choudhary 2018-06-05

    FR Passed. PR Merged.
  5. Joshua Quick 2018-06-05

    Everyone, For your info, this issue only happens on Android 8.0 and newer OS versions... and if the app targets API Level 26+ or it targets a lower API Level but the app's "Battery Usage/Background Activity" is switched off under device settings. What is going on is that Android 8 now disallows "Services" to be started in the background if the app does not have any active activity windows. This can happen in Titanium if a push notification is received while the app has not displayed any windows yet. https://developer.android.com/about/versions/oreo/android-8.0-changes#back-all
  6. Lokesh Choudhary 2018-06-05

    Verified the fix in SDK 7.3.0.v20180604180041 & 7.2.0.v20180605053055. Closing.

JSON Source