ApplicationNotResponding: ANR in LifecycleMonitorAndroid
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- mobile, performance
Research direction
Start at LifecycleMonitorAndroid.updateLifecycleState and trace the ActivityLifecycleCallbacks registration triggered after MapboxOptions.accessToken is set. Reproduce with an Application.onCreate initialization and an activity without a MapView; done means activity resume no longer causes a main-thread ANR.
Written by the indexing model from the issue text.
Description
Environment
- Android OS version: 16
- Devices affected: Samsung SM-F966U1
- Maps SDK Version: 11.17.1
Observed behavior and steps to reproduce
ANR in LifecycleMonitorAndroid.updateLifecycleState() during activity resume
The app experiences ANRs when any activity resumes, even activities that don't contain a MapView. The ANR occurs in Mapbox's internal lifecycle monitoring.
Stack trace:
io.sentry.android.core.ApplicationNotResponding: ANR
at com.mapbox.common.LifecycleMonitorAndroid.updateLifecycleState(unavailable:0)
at com.mapbox.common.LifecycleMonitorAndroid.access$updateLifecycleState(unavailable:0)
at com.mapbox.common.LifecycleMonitorAndroid$lifecycleServiceCallback$1.onLifecycleStateChanged(unavailable:7)
at com.mapbox.common.LifecycleService.updateLifecycleState(unavailable:13)
at com.mapbox.common.LifecycleService.getLifecycleState(SourceFile:12)
at com.mapbox.common.LifecycleService.registerActivityWithState(unavailable:111)
at com.mapbox.common.LifecycleService.access$registerActivityWithState(unavailable:0)
at com.mapbox.common.LifecycleService$callback$1.onActivityResumed(unavailable:10)
at android.app.Application.dispatchActivityResumed(Application.java:450)
at android.app.Activity.dispatchActivityResumed(Activity.java:1686)
at android.app.Activity.onResume(Activity.java:2287)
at androidx.fragment.app.FragmentActivity.onResume(unavailable:5)
at com.example.app.onboarding.OnboardingActivity.onResume(unavailable:0)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1720)
at android.app.Activity.performResume(Activity.java:9691)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:6162)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:6265)
...
Steps to reproduce:
- Initialize Mapbox SDK in
Application.onCreate()by settingMapboxOptions.accessToken - Launch any activity (doesn't need to contain a MapView)
- Observe ANR during
onResume()in Mapbox's lifecycle callback
Expected behavior
LifecycleMonitorAndroid.updateLifecycleState() should not block the main thread and cause ANRs. Lifecycle state updates should be fast and non-blocking, or performed asynchronously.
Notes / preliminary analysis
- It rarely happens
- The ANR occurs in activities that have no MapView or map-related functionality
- Once
MapboxOptions.accessTokenis set, Mapbox registersActivityLifecycleCallbacksthat run on every activity lifecycle event - The
updateLifecycleState()method appears to perform blocking operations - There is no API available to disable or configure this automatic lifecycle monitoring
- This affects user experience even when maps are not being displayed
Additional links and references
- Related to lifecycle monitoring introduced in Mapbox Maps SDK v11
- Using
com.mapbox.maps:android-ndk27:11.17.1
- Dominant language
- Kotlin
- Stars
- 577
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/mapbox-maps-android
-
bug :beetle:
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
mapbox/mapbox-maps-android#2727 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
mapbox/mapbox-maps-android#2733 ·
-
bug :beetle:
Difficulty 4/5 3-5 days Newbie friendliness 50/100
mapbox/mapbox-maps-android#2732 ·
-
auto-triaged bug :beetle:
Difficulty 4/5 3-5 days Newbie friendliness 45/100
mapbox/mapbox-maps-android#2731 · 4 reactions ·
-
bug :beetle:
Difficulty 4/5 3-5 days Newbie friendliness 48/100
mapbox/mapbox-maps-android#2730 ·
All issues in mapbox/mapbox-maps-android
Similar issues
-
bug status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
LawnchairLauncher/lawnchair#7360 · 1 comment ·
Maintainers usually reply within 1 day
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ankidroid/Anki-Android#22298 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
trakt/trakt-android#425 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Raijin Scans (FR)Possibly taken A pull request linked to this issue is open or already merged. OpenBug Domain changed
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
keiyoushi/extensions-source#19644 · 1 reaction ·
Maintainers usually reply within 1 day