You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Currently, it is possible to fall into the following trap:
Create and display an MGLMapView in an application's UIViewController
In -[MGLMapViewDelegate mapView:didFinishLoadingStyle:], create and add a shape source and layer
Store a reference (i.e. property) to the added source in the app's view controller
Sometime later, set a new style
When the new style loads, attempt to mutate the shape of the shape source via the property reference
Because the source in the previous steps is tied to the previous style that is in the process of being replaced by the new style, the application will crash with traces that can change as a function of where the previous style unloading process is and the state of the mbgl::style::GeoJSONSource (that becomes invalid and dangerous to attempt to mutate). A partial example of such a trace is:
Mapbox`mbgl::style::GeoJSONSource::Impl::setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> > const&) [inlined] std::__1::unique_ptr<mbgl::AsyncRequest, std::__1::default_delete<mbgl::AsyncRequest> >::reset(this=0x0000000000772f16, __p=0x0000000000000000) at memory:2733
frame #1: 0x000000010544d3d1 Mapbox`mbgl::style::GeoJSONSource::Impl::setGeoJSON(this=0x0000000000772e36, geoJSON=0x00007fff5b641550) at geojson_source_impl.cpp:56
frame #2: 0x000000010544c581 Mapbox`mbgl::style::GeoJSONSource::setGeoJSON(this=0x0000608000429e40, geoJSON=0x00007fff5b641550) at geojson_source.cpp:18
frame #3: 0x0000000104c0f3a0 Mapbox`::-[MGLShapeSource setShape:](self=0x0000600000056f20, _cmd="setShape:", shape=0x00006000002c5d30) at MGLShapeSource.mm:130
frame #4: 0x00000001045d9148 Mapbox GL`__51-[MBXViewController mapView:didFinishLoadingStyle:]_block_invoke((null)=0x0000608000058ea0) at MBXViewController.m:1847
Workarounds for this issue include recreating and adding the source and layer stack each time a style loads or only adding the source/layer to a specific style and also using APIs like -[MGLStyle sourceWithIdentifier:] instead of keeping references to sources in objects in the application space.
#6180 tracks a feature to persist sources and layers across style changes. Additionally improvements like #6386 and #7988 would help with the ergonomics in this area.
In the meantime, we should consider adding better exception handling and documentation to help guide developers around this trap. The somewhat random stack traces we get now make it hard to understand the underlying problem and how to work around it.
The text was updated successfully, but these errors were encountered:
Currently, it is possible to fall into the following trap:
MGLMapView
in an application'sUIViewController
-[MGLMapViewDelegate mapView:didFinishLoadingStyle:]
, create and add a shape source and layershape
of the shape source via the property referenceBecause the source in the previous steps is tied to the previous style that is in the process of being replaced by the new style, the application will crash with traces that can change as a function of where the previous style unloading process is and the state of the
mbgl::style::GeoJSONSource
(that becomes invalid and dangerous to attempt to mutate). A partial example of such a trace is:Workarounds for this issue include recreating and adding the source and layer stack each time a style loads or only adding the source/layer to a specific style and also using APIs like
-[MGLStyle sourceWithIdentifier:]
instead of keeping references to sources in objects in the application space.#6180 tracks a feature to persist sources and layers across style changes. Additionally improvements like #6386 and #7988 would help with the ergonomics in this area.
In the meantime, we should consider adding better exception handling and documentation to help guide developers around this trap. The somewhat random stack traces we get now make it hard to understand the underlying problem and how to work around it.
The text was updated successfully, but these errors were encountered: