Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add layer failed: bad_variant_access #2342

Open
Ashok-Media opened this issue Apr 12, 2024 · 3 comments
Open

Add layer failed: bad_variant_access #2342

Ashok-Media opened this issue Apr 12, 2024 · 3 comments
Labels
bug 🪲 Something isn't working

Comments

@Ashok-Media
Copy link

Environment

  • Android OS version: Android 12
  • Devices affected: Galaxy A12
  • Maps SDK Version: 11.0.0

Observed behavior and steps to reproduce

Not able to reproduce this crash however happening in live for few users

Fatal Exception: com.mapbox.maps.MapboxStyleException: Add layer failed: bad_variant_access at com.mapbox.maps.extension.style.layers.Layer.bindTo(Layer.java:154) at com.mapbox.maps.extension.style.layers.LayerUtils.addLayerBelow(:16) at com.launcher.android.radarhome.presentation.ui.radar.ui.RadarFragment$initObservers$5.invoke$lambda$6$lambda$5(RadarFragment.java:219) at com.mapbox.maps.StyleObserver.run(:36) at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:335) at android.os.Looper.loopOnce(Looper.java:186) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8663) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Expected behavior

It should not crash

@Ashok-Media Ashok-Media added the bug 🪲 Something isn't working label Apr 12, 2024
@kiryldz
Copy link
Contributor

kiryldz commented Apr 12, 2024

@Ashok-Media without context it's rather hard to say when this could happen. If you will not be able to provide more context when exactly this might happen in your app (e.g. on style change, app went to background) I would suggest you:

  1. Try update to later version (v11.3.0).
  2. If crash is still there - simply catch our dedicated MapboxStyleException in your code and, perhaps, gather more data that you could share with us so that this issue becomes actionable from our end.

Closing this for now, feel free to re-open if you would have more data.

@kiryldz kiryldz closed this as completed Apr 12, 2024
@Ashok-Media
Copy link
Author

Ashok-Media commented Apr 12, 2024

as per the log this crash is occur inside the loadstyle(style) block
mapboxMap?.loadStyle(currentStyle) { style -> if (style.isValid()) { rasterLayers?.forEach { rasterLayer: RasterLayer -> style.addLayerBelow( rasterLayer, RadarUtils.getLayerId(radarViewModel.mapStyleChangeLiveData.value), ) } } }

@kiryldz
Copy link
Contributor

kiryldz commented Apr 12, 2024

@Ashok-Media please do not open new issues duplicating existing ones. Thanks for the code, sadly it's not enough to say why it could lead to a crash, generally looks valid (and as you said, it crashes for few users only). I'll leave this issue open until more information will be provided.

gj-loitp pushed a commit to gj-loitp/lib_mapbox-maps-android that referenced this issue May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants