Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Avoid null-change KVO notifications #1748

Merged
merged 1 commit into from
Jun 18, 2015
Merged

Avoid null-change KVO notifications #1748

merged 1 commit into from
Jun 18, 2015

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Jun 17, 2015

If no access token is set in the Info.plist, avoid triggering a KVO notification about the access token changing. By the same token (heh), avoid pulling a C string out of the change dictionary if the access token is being nilled out.

Fixes a bug introduced in 90a50c0 for #1553.

/cc @incanus

If no access token is set in the Info.plist, avoid triggering a KVO notification about the access token changing. By the same token (heh), avoid pulling a C string out of the change dictionary if the access token is being nilled out.
@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS crash labels Jun 17, 2015
@1ec5 1ec5 added this to the iOS Beta 2 milestone Jun 17, 2015
@incanus
Copy link
Contributor

incanus commented Jun 18, 2015

Now I get a crash in nornmalizeURL() if I don't set a token, with no message.

#1  0x000000010a9dbbd7 in mbgl::util::mapbox::normalizeURL(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&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) ()
#2  0x000000010a9dbd14 in mbgl::util::mapbox::normalizeSourceURL(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&) ()
#3  0x000000010a980e3b in mbgl::DefaultFileSource::request(mbgl::Resource const&, uv_loop_s*, std::__1::function<void (mbgl::Response const&)>) ()
#4  0x000000010a9316df in mbgl::Environment::request(mbgl::Resource const&, std::__1::function<void (mbgl::Response const&)>) ()
#5  0x000000010a949cbe in mbgl::Source::load() ()
#6  0x000000010a993f53 in mbgl::Style::Style(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&, uv_loop_s*, mbgl::Environment&) ()
#7  0x000000010a940c6a in mbgl::MapContext::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&) ()
#8  0x000000010a984ce2 in mbgl::Request::notifyCallback() ()
#9  0x000000010aa1a5ae in uv__async_event at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/async.c:80
#10 0x000000010aa1a998 in uv__async_io at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/async.c:156
#11 0x000000010aa363ae in uv__io_poll at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/kqueue.c:233
#12 0x000000010aa1b0a3 in uv_run at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/core.c:317
#13 0x000000010a93ff83 in void mbgl::util::Thread<mbgl::MapContext>::run<std::__1::tuple<mbgl::View&, mbgl::FileSource&, mbgl::MapData&>, 0ul, 1ul, 2ul>(std::__1::tuple<mbgl::View&, mbgl::FileSource&, mbgl::MapData&>&&, std::__1::integer_sequence<unsigned long, 0ul, 1ul, 2ul>) ()
#14 0x000000010a93feaf in std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::MapContext>::Thread<mbgl::View&, mbgl::FileSource&, mbgl::MapData&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, mbgl::util::ThreadPriority, mbgl::View&&&, mbgl::FileSource&&&, mbgl::MapData&&&)::'lambda'()> >(void*, void*) ()
#15 0x000000010e8a2268 in _pthread_body ()
#16 0x000000010e8a21e5 in _pthread_start ()
#17 0x000000010e8a041d in thread_start ()

Still testing as per #1746 (comment).

@1ec5
Copy link
Contributor Author

1ec5 commented Jun 18, 2015

@incanus, that is the intended location of the assertion. You’ve probably got an exception breakpoint; the message can’t be printed until you continue.

@1ec5
Copy link
Contributor Author

1ec5 commented Jun 18, 2015

We shouldn’t throw an exception up at the Cocoa level because there may be legitimate reasons for not specifying an access token, namely that the app is using a local style and non-Mapbox-hosted source.

@incanus
Copy link
Contributor

incanus commented Jun 18, 2015

Doh, yep. Looking good with the stripped library and exceptions:

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: You must provide a Mapbox API access token for Mapbox tile sources

incanus added a commit that referenced this pull request Jun 18, 2015
Avoid null-change KVO notifications
@incanus incanus merged commit 6fba146 into master Jun 18, 2015
@incanus incanus deleted the 1ec5-null-change branch June 18, 2015 04:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants