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

Crash switching back to app — mbgl::Channel<mbgl::Worker::work>::send() #1277

Closed
1ec5 opened this issue Apr 15, 2015 · 6 comments
Closed
Assignees
Labels
crash iOS Mapbox Maps SDK for iOS
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Apr 15, 2015

The iOS demo app often crashes when switching away from the app while it’s animating then switching back to the app:

Map (190)#0 0x00000001932c53f0 in __cxa_throw ()
#1  0x0000000193298c78 in std::__1::__throw_system_error(int, char const*) ()
#2  0x0000000100352210 in std::__1::unique_lock<std::__1::mutex>::unique_lock(std::__1::mutex&) [inlined] at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__mutex_base:108
#3  0x00000001003521e8 in std::__1::unique_lock<std::__1::mutex>::unique_lock(std::__1::mutex&) [inlined] at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__mutex_base:108
#4  0x00000001003521dc in mbgl::Channel<mbgl::Worker::Work>::send(mbgl::Worker::Work const&) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/util/channel.hpp:16
#5  0x0000000100350de0 in mbgl::Worker::send(std::__1::function<void ()>, std::__1::function<void ()>) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/util/worker.cpp:41
#6  0x0000000100178568 in mbgl::TileData::reparse(mbgl::Worker&, std::__1::function<void ()>) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/tile_data.cpp:62
#7  0x000000010017c74c in mbgl::TileData::request(mbgl::Worker&, float, std::__1::function<void ()>)::$_0::operator()(mbgl::Response const&) const at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/tile_data.cpp:46
#8  0x000000010017c2b0 in decltype(std::__1::forward<mbgl::TileData::request(mbgl::Worker&, float, std::__1::function<void ()>)::$_0&>(fp)(std::__1::forward<mbgl::Response const&>(fp0))) std::__1::__invoke<mbgl::TileData::request(mbgl::Worker&, float, std::__1::function<void ()>)::$_0&, mbgl::Response const&>(mbgl::TileData::request(mbgl::Worker&, float, std::__1::function<void ()>)::$_0&&&, mbgl::Response const&&&) [inlined] at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:413
#9  0x000000010017c290 in std::__1::__function::__func<mbgl::TileData::request(mbgl::Worker&, float, std::__1::function<void ()>)::$_0, std::__1::allocator<mbgl::TileData::request(mbgl::Worker&, float, std::__1::function<void ()>)::$_0>, void (mbgl::Response const&)>::operator()(mbgl::Response const&) at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1370
#10 0x000000010023a2f4 in std::__1::function<void (mbgl::Response const&)>::operator()(mbgl::Response const&) const at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1756
#11 0x0000000100239470 in mbgl::Request::invoke() at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/storage/request.cpp:57
#12 0x000000010023927c in mbgl::Request::notifyCallback() at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/storage/request.cpp:38
#13 0x000000010023a19c in mbgl::Request::Request(mbgl::Resource const&, uv_loop_s*, mbgl::Environment const&, std::__1::function<void (mbgl::Response const&)>)::$_0::operator()(uv_async_s*, int) const at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/storage/request.cpp:27
#14 0x000000010023a134 in mbgl::Request::Request(mbgl::Resource const&, uv_loop_s*, mbgl::Environment const&, std::__1::function<void (mbgl::Response const&)>)::$_0::__invoke(uv_async_s*, int) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/storage/request.cpp:27
#15 0x00000001003c5ab0 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
#16 0x00000001003c5ed4 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
#17 0x00000001003e2564 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
#18 0x00000001003c6630 in uv_run at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/core.c:317
#19 0x0000000100129990 in mbgl::Map::run() at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:278
#20 0x000000010013a6c8 in mbgl::Map::start(bool)::$_5::operator()() const at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/map/map.cpp:177
#21 0x000000010013a4b0 in decltype(std::__1::forward<mbgl::Map::start(bool)::$_5>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<mbgl::Map::start(bool)::$_5>(mbgl::Map::start(bool)::$_5&&) [inlined] at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:413
#22 0x000000010013a4a4 in void std::__1::__thread_execute<mbgl::Map::start(bool)::$_5>(std::__1::tuple<mbgl::Map::start(bool)::$_5>&, std::__1::__tuple_indices<>) [inlined] at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:332
#23 0x000000010013a494 in void* std::__1::__thread_proxy<std::__1::tuple<mbgl::Map::start(bool)::$_5> >(void*) at /Applications/Xcode+1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:342
#24 0x000000019430fdc8 in _pthread_body ()
#25 0x000000019430fd24 in _pthread_start ()

worker appears to be bogus by the time mbgl::TileData::reparse() is called.

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS crash labels Apr 15, 2015
@1ec5
Copy link
Contributor Author

1ec5 commented Apr 15, 2015

@jfirebaugh jfirebaugh added this to the iOS Beta 1 milestone Apr 16, 2015
@kkaefer
Copy link
Contributor

kkaefer commented Apr 16, 2015

The Worker object has been destructed when it's called.

@jfirebaugh
Copy link
Contributor

Should I be able to reproduce this in the simulator?

@jfirebaugh jfirebaugh self-assigned this Apr 16, 2015
@1ec5
Copy link
Contributor Author

1ec5 commented Apr 16, 2015

Should be able to.

@jfirebaugh
Copy link
Contributor

VectorTileData outlives its worker when it hasn't done style.reset() by the time backgrounding the app ⇢ Map::stop ⇢ asyncTerminate ⇢ workers.reset() occurs. In that case, the style is being retained by the tile, so sources and all the tiles are also retained (cycle), and any pending requests can still be fulfilled, but the workers are gone.

The reference cycle is causing us huge problems, we have to break that.

@jfirebaugh
Copy link
Contributor

This will be fixed by #1065.

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

No branches or pull requests

3 participants