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

Hang when canceling in-progress snapshots #16530

Open
1ec5 opened this issue Mar 16, 2020 · 4 comments
Open

Hang when canceling in-progress snapshots #16530

1ec5 opened this issue Mar 16, 2020 · 4 comments

Comments

@1ec5
Copy link
Contributor

1ec5 commented Mar 16, 2020

The “Show Snapshots” command in iosapp seems to expose a hang in the snapshotter. For example, if MBXSnapshotsViewController looks like this:

last-two

then these two snapshotters haven’t finished:

https://github.com/mapbox/mapbox-gl-native-ios/blob/9936092d7c48d3eedc5b380d455389a1397d0fd5/platform/ios/app/MBXSnapshotsViewController.m#L40-L41

If I then push Back, the application attempts to cancel the snapshots, but instead the main thread is blocked until the snapshots run to completion:

#0	0x00007fff523b8ce6 in __psynch_cvwait ()
mapbox/mapbox-gl-native-ios#1	0x00007fff52467185 in _pthread_cond_wait ()
mapbox/mapbox-gl-native-ios#2	0x00007fff50202eda in std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) ()
mapbox/mapbox-gl-native-ios#3	0x00007fff50203801 in std::__1::__assoc_sub_state::__sub_wait(std::__1::unique_lock<std::__1::mutex>&) ()
mapbox/mapbox-gl-native-ios#4	0x00007fff5020375a in std::__1::__assoc_sub_state::copy() ()
mapbox/mapbox-gl-native-ios#5	0x00007fff5020399d in std::__1::future<void>::get() ()
mapbox/mapbox-gl-native-ios#6	0x00000001060d4bd4 in mbgl::util::Thread<mbgl::SnapshotterRenderer>::~Thread() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/include/mbgl/util/thread.hpp:98
mapbox/mapbox-gl-native-ios#7	0x00000001060d4b15 in mbgl::util::Thread<mbgl::SnapshotterRenderer>::~Thread() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/include/mbgl/util/thread.hpp:83
mapbox/mapbox-gl-native-ios#8	0x00000001060d4abb in std::__1::default_delete<mbgl::util::Thread<mbgl::SnapshotterRenderer> >::operator()(mbgl::util::Thread<mbgl::SnapshotterRenderer>*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2339
mapbox/mapbox-gl-native-ios#9	0x00000001060d4a3f in std::__1::unique_ptr<mbgl::util::Thread<mbgl::SnapshotterRenderer>, std::__1::default_delete<mbgl::util::Thread<mbgl::SnapshotterRenderer> > >::reset(mbgl::util::Thread<mbgl::SnapshotterRenderer>*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2652
mapbox/mapbox-gl-native-ios#10	0x00000001060d49d9 in std::__1::unique_ptr<mbgl::util::Thread<mbgl::SnapshotterRenderer>, std::__1::default_delete<mbgl::util::Thread<mbgl::SnapshotterRenderer> > >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#11	0x00000001060d49b5 in std::__1::unique_ptr<mbgl::util::Thread<mbgl::SnapshotterRenderer>, std::__1::default_delete<mbgl::util::Thread<mbgl::SnapshotterRenderer> > >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#12	0x00000001060d4971 in mbgl::SnapshotterRendererFrontend::~SnapshotterRendererFrontend() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:110
mapbox/mapbox-gl-native-ios#13	0x00000001060c82e5 in mbgl::SnapshotterRendererFrontend::~SnapshotterRendererFrontend() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:110
mapbox/mapbox-gl-native-ios#14	0x00000001060da1d1 in mbgl::MapSnapshotter::Impl::~Impl() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:140
mapbox/mapbox-gl-native-ios#15	0x00000001060c8305 in mbgl::MapSnapshotter::Impl::~Impl() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:140
mapbox/mapbox-gl-native-ios#16	0x00000001060c8329 in mbgl::MapSnapshotter::Impl::~Impl() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:140
mapbox/mapbox-gl-native-ios#17	0x00000001060da3ff in std::__1::default_delete<mbgl::MapSnapshotter::Impl>::operator()(mbgl::MapSnapshotter::Impl*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2339
mapbox/mapbox-gl-native-ios#18	0x00000001060da37f in std::__1::unique_ptr<mbgl::MapSnapshotter::Impl, std::__1::default_delete<mbgl::MapSnapshotter::Impl> >::reset(mbgl::MapSnapshotter::Impl*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2652
mapbox/mapbox-gl-native-ios#19	0x00000001060da319 in std::__1::unique_ptr<mbgl::MapSnapshotter::Impl, std::__1::default_delete<mbgl::MapSnapshotter::Impl> >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#20	0x00000001060b75f5 in std::__1::unique_ptr<mbgl::MapSnapshotter::Impl, std::__1::default_delete<mbgl::MapSnapshotter::Impl> >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#21	0x00000001060b75d5 in mbgl::MapSnapshotter::~MapSnapshotter() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:254
mapbox/mapbox-gl-native-ios#22	0x00000001060b7615 in mbgl::MapSnapshotter::~MapSnapshotter() at /path/to/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:254
mapbox/mapbox-gl-native-ios#23	0x0000000105eb4c2b in std::__1::default_delete<mbgl::MapSnapshotter>::operator()(mbgl::MapSnapshotter*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2339
mapbox/mapbox-gl-native-ios#24	0x0000000105eacaef in std::__1::unique_ptr<mbgl::MapSnapshotter, std::__1::default_delete<mbgl::MapSnapshotter> >::reset(mbgl::MapSnapshotter*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2652
mapbox/mapbox-gl-native-ios#25	0x0000000105eaca49 in ::-[MGLMapSnapshotter cancel]() at /path/to/mapbox-gl-native-ios/platform/darwin/src/MGLMapSnapshotter.mm:657
mapbox/mapbox-gl-native-ios#26	0x0000000105ea7d5d in ::-[MGLMapSnapshotter dealloc]() at /path/to/mapbox-gl-native-ios/platform/darwin/src/MGLMapSnapshotter.mm:214
mapbox/mapbox-gl-native-ios#27	0x00007fff514110d6 in objc_object::sidetable_release(bool) ()
mapbox/mapbox-gl-native-ios#28	0x00000001020cf422 in -[MBXSnapshotsViewController .cxx_destruct] at /path/to/mapbox-gl-native-ios/platform/ios/app/MBXSnapshotsViewController.m:19

Originally posted by @1ec5 in mapbox/mapbox-gl-native-ios#210 (comment)

/cc @mapbox/maps-ios @alexshalamov

@alexshalamov
Copy link
Contributor

alexshalamov commented Mar 16, 2020

Can reproduce on master (ios simulator). Hangs in thread's destructor stoppable.get_future().get();

Cannot reproduce on HW (iPhone Xr 13.3)

stack trace
Thread 1 Queue : com.apple.main-thread (serial)
#0	0x00007fff523b8ce6 in __psynch_cvwait ()
mapbox/mapbox-gl-native-ios#1	0x00007fff52467185 in _pthread_cond_wait ()
mapbox/mapbox-gl-native-ios#2	0x00007fff50202eda in std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) ()
mapbox/mapbox-gl-native-ios#3	0x00007fff50203801 in std::__1::__assoc_sub_state::__sub_wait(std::__1::unique_lock<std::__1::mutex>&) ()
mapbox/mapbox-gl-native-ios#4	0x00007fff5020375a in std::__1::__assoc_sub_state::copy() ()
mapbox/mapbox-gl-native-ios#5	0x00007fff5020399d in std::__1::future<void>::get() ()
mapbox/mapbox-gl-native-ios#6	0x0000000103cf2002 in mbgl::util::Thread<mbgl::MapSnapshotter::Impl>::~Thread() at /Users/shalamov/github/mapbox-gl-native-ios/vendor/mapbox-gl-native/include/mbgl/util/thread.hpp:98
mapbox/mapbox-gl-native-ios#7	0x0000000103cf1f45 in mbgl::util::Thread<mbgl::MapSnapshotter::Impl>::~Thread() at /Users/shalamov/github/mapbox-gl-native-ios/vendor/mapbox-gl-native/include/mbgl/util/thread.hpp:83
mapbox/mapbox-gl-native-ios#8	0x0000000103cf1eeb in std::__1::default_delete<mbgl::util::Thread<mbgl::MapSnapshotter::Impl> >::operator()(mbgl::util::Thread<mbgl::MapSnapshotter::Impl>*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2339
mapbox/mapbox-gl-native-ios#9	0x0000000103cf1e6f in std::__1::unique_ptr<mbgl::util::Thread<mbgl::MapSnapshotter::Impl>, std::__1::default_delete<mbgl::util::Thread<mbgl::MapSnapshotter::Impl> > >::reset(mbgl::util::Thread<mbgl::MapSnapshotter::Impl>*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2652
mapbox/mapbox-gl-native-ios#10	0x0000000103cf1e09 in std::__1::unique_ptr<mbgl::util::Thread<mbgl::MapSnapshotter::Impl>, std::__1::default_delete<mbgl::util::Thread<mbgl::MapSnapshotter::Impl> > >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#11	0x0000000103ce2815 in std::__1::unique_ptr<mbgl::util::Thread<mbgl::MapSnapshotter::Impl>, std::__1::default_delete<mbgl::util::Thread<mbgl::MapSnapshotter::Impl> > >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#12	0x0000000103ce27f5 in mbgl::MapSnapshotter::~MapSnapshotter() at /Users/shalamov/github/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:175
mapbox/mapbox-gl-native-ios#13	0x0000000103ce2835 in mbgl::MapSnapshotter::~MapSnapshotter() at /Users/shalamov/github/mapbox-gl-native-ios/vendor/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp:175
mapbox/mapbox-gl-native-ios#14	0x0000000103ad7cab in std::__1::default_delete<mbgl::MapSnapshotter>::operator()(mbgl::MapSnapshotter*) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2339
mapbox/mapbox-gl-native-ios#15	0x0000000103ace4df in std::__1::unique_ptr<mbgl::MapSnapshotter, std::__1::default_delete<mbgl::MapSnapshotter> >::reset(mbgl::MapSnapshotter*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2652
mapbox/mapbox-gl-native-ios#16	0x0000000103adf879 in std::__1::unique_ptr<mbgl::MapSnapshotter, std::__1::default_delete<mbgl::MapSnapshotter> >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#17	0x0000000103ad57d5 in std::__1::unique_ptr<mbgl::MapSnapshotter, std::__1::default_delete<mbgl::MapSnapshotter> >::~unique_ptr() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2606
mapbox/mapbox-gl-native-ios#18	0x0000000103ad5a43 in ::-[MGLMapSnapshotter .cxx_destruct]() at /Users/shalamov/github/mapbox-gl-native-ios/platform/darwin/src/MGLMapSnapshotter.mm:200
mapbox/mapbox-gl-native-ios#19	0x00007fff513faf02 in object_cxxDestructFromClass(objc_object*, objc_class*) ()

/cc @tmpsantos

@chloekraw
Copy link
Contributor

chloekraw commented Mar 17, 2020

@alexshalamov @tmpsantos thank you for reproducing -- let's prioritize this investigation and fix this sprint so it can be addressed in a GL Native 1.4.2 patch before the next Maps SDK stable release in two weeks.

@julianrex
Copy link
Contributor

@alexshalamov was there any progress here?

@fabian-guerra fabian-guerra transferred this issue from mapbox/mapbox-gl-native-ios Sep 9, 2020
@fabian-guerra fabian-guerra removed their assignment Sep 9, 2020
@fabian-guerra
Copy link
Contributor

Since the block happens on GL. I am transferring this issue to this repo. I can confirm that this happens on simulator. I couldn't reproduce on a device (iPhone 11/X iOS 13/14 respectively).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants