mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
476 stars 133 forks source link

Crash in MapboxTelemetry : Caused by com.mapbox.common.module.provider.MapboxInvalidModuleException #1540

Closed dh-hasif closed 3 weeks ago

dh-hasif commented 2 years ago

Environment

Observed behavior and steps to reproduce

We are reporting several crashes in production from some set of users, and the stack trace is as follows

Caused by com.mapbox.common.module.provider.MapboxInvalidModuleException MapTelemetry has been excluded from build but a correct alternative was not provided. Make sure that: - Your custom module implements com.mapbox.maps.module.MapTelemetry. - Your custom module class is annotated with @a(b.MapTelemetry). - You've provided aModuleProviderinstance to Mapbox_MapTelemetryModuleConfiguration#setModuleProvider before initializing the library, unlessenableConfigurationflag is set to false and your implementation has a public, non-arg constructor or is a Kotlin object.

com.mapbox.common.module.provider.MapboxModuleProvider.createModule (MapboxModuleProvider.kt:88) com.mapbox.maps.MapController.dispatchTelemetryTurnstileEvent (MapController.kt:214) com.mapbox.maps.MapController.<init> (MapController.kt:77) com.mapbox.maps.MapView.<init> (MapView.kt:101) com.mapbox.maps.MapView.<init> (MapView.kt:69) com.mapbox.maps.MapView.<init> (MapView.kt:63) java.lang.reflect.Constructor.newInstance0 (Constructor.java) java.lang.reflect.Constructor.newInstance (Constructor.java:343) android.view.LayoutInflater.createView (LayoutInflater.java:852) android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:1008) android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:959) android.view.LayoutInflater.rInflate (LayoutInflater.java:1138) android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:1099) android.view.LayoutInflater.inflate (LayoutInflater.java:680) android.view.LayoutInflater.inflate (LayoutInflater.java:532) com.foodora.courier.map.enabled.presentation.MapboxFragment.onCreateView (MapboxFragment.kt:153) androidx.fragment.app.Fragment.performCreateView (Fragment.java:2995) androidx.fragment.app.FragmentStateManager.createView (FragmentStateManager.java:523) androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:261) androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:1840) androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:1758) androidx.fragment.app.FragmentManager.execPendingActions (FragmentManager.java:1701) androidx.fragment.app.FragmentManager.dispatchStateChange (FragmentManager.java:2849) androidx.fragment.app.FragmentManager.dispatchStart (FragmentManager.java:2791) androidx.fragment.app.Fragment.performStart (Fragment.java:3062) androidx.fragment.app.FragmentStateManager.start (FragmentStateManager.java:587) androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:279) androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:1840) androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:1758) androidx.fragment.app.FragmentManager.execSingleAction (FragmentManager.java:1670) androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:323) androidx.fragment.app.FragmentStatePagerAdapter.finishUpdate (FragmentStatePagerAdapter.java:274) androidx.viewpager.widget.ViewPager.populate (ViewPager.java:1244) androidx.viewpager.widget.ViewPager.populate (ViewPager.java:1092) androidx.viewpager.widget.ViewPager.onMeasure (ViewPager.java:1622) android.view.View.measure (View.java:25960) android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7112) android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1552) android.widget.LinearLayout.measureVertical (LinearLayout.java:842) android.widget.LinearLayout.onMeasure (LinearLayout.java:721) android.view.View.measure (View.java:25960) android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7112) androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasureChild (CoordinatorLayout.java:760) androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure (CoordinatorLayout.java:833) android.view.View.measure (View.java:25960)

we are not currently not able to reproduce this in our test device, but this crash is occurring for some set of users in production app and we are receiving events in crashlytics

Expected behavior

MapView should not crash during inflation

dh-hasif commented 2 years ago

this crash is spiking for users.

yunikkk commented 2 years ago

this crash is spiking for users.

@dh-hasif have it started spiking after Maps update or with old version?

dh-hasif commented 2 years ago

@yunikkk currently our app points to maps SDK 10.3.0 but I could also see an issue reported on maps SDK 10.6.0 https://github.com/mapbox/mapbox-maps-android/issues/1475

and this crash is spiking for users.

Screenshot 2022-08-03 at 12 45 49

and we could see this happening for various devices like OPPO, Realme, Nubia, Huawei.

dh-hasif commented 2 years ago

We tried this solution as provided in this comment https://github.com/mapbox/mapbox-maps-android/issues/1475#issuecomment-1210381808. we are setting access_token via ResourceOptionsManager during application load and passing access_token via XML to Mapview.

but the issue is not fixed, we could still see the exception occurring for some users in production in Firebase crashlytics.

currently, the app is pointing to SDK 10.7.0

cc @moritzzzzz

harikhalsa commented 2 years ago

@dh-hasif would you be able to test out the recommendations in this comment and see if this resolves the crash? It's possible you're seeing this behavior in production because the Playstore uses this app bundle.

dh-hasif commented 2 years ago

@harikhalsa as mentioned in the above comment, this is not the same case in our application, we are not disabling the initialization provider. Even I cross-checked the merged manifest file and I could see all the initialization providers for Mapbox added.

Yes, we were rolling out releases via the app bundle. but this issue came up while we migrated from Mapbox version 9 to 10

jinny-nam commented 2 years ago

hi @dh-hasif,

Can you share if the initialization provider has been disabled before? It appears there are cases the initialization provider is not recovered even after re-enabling it. In this case, it can be enabled properly by this solution that @harikhalsa shared above. Based on issues that we've received from users, this crash issue is likely related an issue in App Bundle, some kind of conflict with the app configuration rather than something wrong with the telemetry module.

But noting that the crash you are experiencing only came up after migrating version 9 to 10, we will investigate further if there could be other causes, and share with you as soon as possible.

On the other hand, looking at this comment and the issue description, this crash was reproducible when the app stayed in background for 20-30 mins and back to front. Have you tested to see if the same situation happens on your side? It seems the user resolved the crash by passing the token using xml (way 1 in the v9-v10 migration guide)

One more question: Is your app still on 10.7.0 and experiencing the crash?

jinny-nam commented 2 years ago

hi @dh-hasif, we are working to fix this issue in the sdk. I will keep you posted about the updates.

jinny-nam commented 2 years ago

hi @dh-hasif, would you be able to implement Maps SDK v10.8.1 and see if it resolves the crash? We've include a change where we optimise the telemetry module's initialisation and we think this may resolve the crash.

kiryldz commented 3 weeks ago

Stale, outdated.