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 was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Crash on launch without access token — mbgl::Style::loadJSON() #1147
Every time I launch the iOS demo app in various older iOS simulators (e.g., iPhone 4s or iPad 2 with iOS 8.2), I get the following crash:
Map (13)
#0 0x038fe695 in __cxa_throw ()
#1 0x0027b784 in mbgl::Style::loadJSON(unsigned char const*) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/style/style.cpp:75
#2 0x0012c9ab in mbgl::Map::loadStyleJSON(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:807
#3 0x0012c581 in mbgl::Map::reloadStyle() at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:797
#4 0x00125be4 in mbgl::Map::prepare() at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:822
#5 0x00125535 in mbgl::Map::run() at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:279
#6 0x0013b366 in mbgl::Map::start(bool)::$_5::operator()() const at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:183
…
Map::data is completely empty at this point: no json and no base. Those values wouldn’t be filled in until -[MGLMapView initWithFrame::accessToken:styleJSON:] calls -setStyleJSON: later on.
changed the title [-]Crash on launch in non-Retina iOS simulators — mbgl::Style::loadJSON()[/-][+]Crash on launch in older iOS simulators — mbgl::Style::loadJSON()[/+]on Mar 27, 2015
I’m not sure that’s related. What I’m seeing here is that the style URL is never set by the time the Map thread tries to parse the JSON (due to the absence of a style URL).
This is where StyleInfo is set on the iPhone 6 simulator:
#0 0x0000000105926320 in mbgl::MapData::setStyleInfo(mbgl::StyleInfo&&) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map_data.hpp:33
#1 0x0000000105909d9d in mbgl::Map::setStyleURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:409
#2 0x0000000105b92db9 in -[MGLMapView setStyleURL:] at /Users/mxn/hub/mapbox-gl-native-2/platform/ios/MGLMapView.mm:177
#3 0x0000000105ba40b0 in -[MGLMapView useBundledStyleNamed:] at /Users/mxn/hub/mapbox-gl-native-2/platform/ios/MGLMapView.mm:1273
#4 0x0000000105b928a4 in -[MGLMapView setStyleJSON:] at /Users/mxn/hub/mapbox-gl-native-2/platform/ios/MGLMapView.mm:165
#5 0x0000000105b91f7e in -[MGLMapView initWithFrame:accessToken:styleJSON:] at /Users/mxn/hub/mapbox-gl-native-2/platform/ios/MGLMapView.mm:115
#6 0x0000000105b92344 in -[MGLMapView initWithFrame:accessToken:] at /Users/mxn/hub/mapbox-gl-native-2/platform/ios/MGLMapView.mm:137
#7 0x0000000105857c28 in -[MBXViewController viewDidLoad] at /Users/mxn/hub/mapbox-gl-native-2/ios/app/MBXViewController.mm:66
The iPhone 4s simulator never gets here before the Map thread tries to parse JSON out of the StyleInfo.
I also get this crash now when I put an MGLMapView in a storyboard (#1070) and set its accessToken as a user-defined runtime attribute instead of setting it in code.
changed the title [-]Crash on launch in older iOS simulators — mbgl::Style::loadJSON()[/-][+]Crash on launch without access token — mbgl::Style::loadJSON()[/+]on Mar 30, 2015
#1163 just compounds the fact that we have too many ways to populate MGLMapView with a style:
accessToken → default bundled style
styleJSON
Bundled style name
accessToken + styleURL (in two flavors)
and we’ll need a separate styleID for IB users to input Mapbox style IDs, since you can’t have a user-defined runtime attribute of type NSURL
Each of these ways complicates my approach of only starting the mbgl::Map when we have enough information to be guaranteed a style. I’m going to try to funnel the various methods into one place that’s responsible for starting the map.
Activity
incanus commentedon Mar 27, 2015
Can't seem to find it now, but I had flagged an issue for @peter related to
floatvalues in the half-sized1xsprite JSON. Looks very similar.incanus commentedon Mar 27, 2015
P.S. Isn't 4s retina?
1ec5 commentedon Mar 27, 2015
Whoops, you’re right, forgot to edit that part.
incanus commentedon Mar 27, 2015
mapbox/mapbox-gl-styles#43 (comment)
[-]Crash on launch in non-Retina iOS simulators — mbgl::Style::loadJSON()[/-][+]Crash on launch in older iOS simulators — mbgl::Style::loadJSON()[/+]1ec5 commentedon Mar 27, 2015
I’m not sure that’s related. What I’m seeing here is that the style URL is never set by the time the Map thread tries to parse the JSON (due to the absence of a style URL).
1ec5 commentedon Mar 27, 2015
This is where
StyleInfois set on the iPhone 6 simulator:The iPhone 4s simulator never gets here before the Map thread tries to parse JSON out of the
StyleInfo.1ec5 commentedon Mar 27, 2015
Doesn’t reproduce if I put in my access token.
1ec5 commentedon Mar 27, 2015
I also get this crash now when I put an
MGLMapViewin a storyboard (#1070) and set itsaccessTokenas a user-defined runtime attribute instead of setting it in code.incanus commentedon Mar 28, 2015
@kkaefer Want to take a peek?
[-]Crash on launch in older iOS simulators — mbgl::Style::loadJSON()[/-][+]Crash on launch without access token — mbgl::Style::loadJSON()[/+]Refactored MGLMapView initialization
1ec5 commentedon Mar 31, 2015
#1163 just compounds the fact that we have too many ways to populate
MGLMapViewwith a style:accessToken→ default bundled stylestyleJSONaccessToken+styleURL(in two flavors)styleIDfor IB users to input Mapbox style IDs, since you can’t have a user-defined runtime attribute of typeNSURLEach of these ways complicates my approach of only starting the
mbgl::Mapwhen we have enough information to be guaranteed a style. I’m going to try to funnel the various methods into one place that’s responsible for starting the map.incanus commentedon Mar 31, 2015
We are getting rid of:
And I think we should keep the IB interaction to just map ID for simplicity & not have to cover every use case.
1ec5 commentedon Mar 31, 2015
OK, since my refactoring mucks around with both APIs, I’m going to tackle removing them along the way.
Fixed race condition after setting access token