mapbox/mapbox-gl-native-ios

iOS SDK crashing when adding multiple sources in a loop using `-[MGLStyle addSource:]`

marcinmatczuk opened this issue · 0 comments

Steps to reproduce

  1. Add multiple sources in a loop by calling -[MGLStyle addSource:] in -[MGLMapViewDelegate mapView:didFinishLoadingStyle:]

Expected behavior

No crash. All soures added.

Actual behavior

Crash:

libc++abi.dylib: terminating with uncaught exception of type mapbox::util::bad_variant_access
terminating with uncaught exception of type mapbox::util::bad_variant_access

Other

I had a quick look at C++ impl of addSource and it seems to register observes that notify once source is added/loaded (e.g. onSourceLoaded), but this is not exposed to iOS SDK and my question is: is there some synchronisation mechanism in place or when should I add next source, so I'm sure style is ready to receive it?

Configuration

Mapbox SDK versions: 6.3.0
iOS/macOS versions: iOS 14.4
Device/simulator models: iPhone 12 mini, iPhone 11, iPhone 8, and simulators (all devices are affected I believe)
Xcode version: 12.4