Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
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

Closed

Description

@1ec5

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.

Activity

  1. added
    iOS
    on Mar 27, 2015
  2. incanus commented on Mar 27, 2015

    @incanus
    Contributor

    Can't seem to find it now, but I had flagged an issue for @peter related to float values in the half-sized 1x sprite JSON. Looks very similar.

  3. added this to the iOS Beta 1 milestone on Mar 27, 2015
  4. incanus commented on Mar 27, 2015

    @incanus
    Contributor

    P.S. Isn't 4s retina?

  5. 1ec5 commented on Mar 27, 2015

    @1ec5
    ContributorAuthor

    Whoops, you’re right, forgot to edit that part.

  6. incanus commented on Mar 27, 2015

    @incanus
    Contributor
  7. 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
  8. 1ec5 commented on Mar 27, 2015

    @1ec5
    ContributorAuthor

    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).

  9. 1ec5 commented on Mar 27, 2015

    @1ec5
    ContributorAuthor

    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.

  10. 1ec5 commented on Mar 27, 2015

    @1ec5
    ContributorAuthor

    Doesn’t reproduce if I put in my access token.

  11. 1ec5 commented on Mar 27, 2015

    @1ec5
    ContributorAuthor

    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.

  12. incanus commented on Mar 28, 2015

    @incanus
    Contributor

    @kkaefer Want to take a peek?

  13. 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
  14. added a commit that references this issue on Mar 30, 2015
  15. self-assigned this
    on Mar 31, 2015
  16. 1ec5 commented on Mar 31, 2015

    @1ec5
    ContributorAuthor

    #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.

  17. incanus commented on Mar 31, 2015

    @incanus
    Contributor

    We are getting rid of:

    • Passing style JSON
    • Naming a bundled style

    And I think we should keep the IB interaction to just map ID for simplicity & not have to cover every use case.

  18. 1ec5 commented on Mar 31, 2015

    @1ec5
    ContributorAuthor

    OK, since my refactoring mucks around with both APIs, I’m going to tackle removing them along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

crashiOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions