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
472 stars 131 forks source link

Crash through not provided MapTelemetry #1475

Open elcolto opened 2 years ago

elcolto commented 2 years ago

Environment

Observed behavior and steps to reproduce

SDK crashes, when implementing App lies in the background for a plenty of time (~20 min) and is pulled back to front. When a View with a MapBoxMap is started, a crash occurs with following Stacktrace:

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 a `ModuleProvider` instance to Mapbox_MapTelemetryModuleConfiguration#setModuleProvider before initializing the library,
  unless `enableConfiguration` flag is set to false and your implementation has a public, non-arg constructor or is a Kotlin object.
       at com.mapbox.common.module.provider.MapboxModuleProvider.createModule(MapboxModuleProvider.kt:88)
       at com.mapbox.maps.MapController.dispatchTelemetryTurnstileEvent(MapController.kt:222)
       at com.mapbox.maps.MapController.<init>(MapController.kt:76)
       at com.mapbox.maps.MapView.<init>(MapView.kt:104)
       at com.mapbox.maps.MapView.<init>(MapView.kt:72)
       at com.mapbox.maps.MapView.<init>(MapView.kt:66)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
       at android.view.LayoutInflater.createView(LayoutInflater.java:858)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:660)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
       at my.package.databinding.LayoutCustomMapboxMapViewBinding.inflate(LayoutCustomMapboxMapViewBinding.java:50)

Same happens when a Snapshotter is used:

Non-fatal Exception: 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 a `ModuleProvider` instance to Mapbox_MapTelemetryModuleConfiguration#setModuleProvider before initializing the library,
  unless `enableConfiguration` flag is set to false and your implementation has a public, non-arg constructor or is a Kotlin object.
       at com.mapbox.common.module.provider.MapboxModuleProvider.createModule(MapboxModuleProvider.kt:88)
       at com.mapbox.maps.Snapshotter.dispatchTelemetryTurnstileEvent(Snapshotter.kt:94)
       at com.mapbox.maps.Snapshotter.<init>(Snapshotter.kt:54)```

Actually we don't use any custom MpaTelemetry solution expect of giving the user the oportunity opt outing from telemetry

mapView.attribution.setTelemetryEnabled(false)

    private fun AttributionPlugin.setTelemetryEnabled(enabled: Boolean) {
        val telemetry = getMapAttributionDelegate()
            .telemetry()

        telemetry.setUserTelemetryRequestState(enabled)
        if (!enabled) {
            telemetry.disableTelemetrySession()
        }
    }
tobrun commented 2 years ago

Thank you for reporting this issue! This a bit of strange one, atm I can't fully explain why class lookup is failing. The crash occurs at this line:

Would you be able to access the logs that occur just before this happens?

moritzzzzz commented 2 years ago

@tobrun Cross posting from slack:

i tried reproducing this issue ,but it is not happening , from Firebase console i could get only this stacktrace.

elcolto commented 2 years ago

Sorry, for long time no comment...

Actually we had a change of providing the resourceoptions

The crash only happened if we just had an implementation like:

ResourceOptionsManager.getDefault(context, context.getString(R.string.mapbox_access_token))

we never set it via xml before. It may seems that the ResourceOptionsManager invalidates the access token after a plenty of time.

After setting the token via xml attribute mapbox_resourcesAccessToken, the crash doesn't occur anymore

moritzzzzz commented 2 years ago

@elcolto Thank you for letting us know! Would you mind if we close the issue? cc @tobrun

ben-j69 commented 1 year ago

@moritzzzzz you should not close the issue. We have it in our app too. If this function is provided it should work as expected, if not it is an issue that must be solved.

yunikkk commented 1 year ago

@ben-j69 does it mean you're still seeing this crash? Which Maps version are you using? It should be resolved with recent versions.

ben-j69 commented 1 year ago

@yunikkk we are using mapbox 10.10.0 and we are seeing in production : 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 @x50(MapboxModuleType.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.

YatinGarg07 commented 3 months ago

Facing the same issue, not resolved till now?

flasher297 commented 3 months ago

@YatinGarg07 which version of SDK do you use?