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.
Transition loop and eventual crash at flyTo #5833
Copy link
Copy link
Closed
Labels
crashiOSMapbox Maps SDK for iOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Description
Mapbox SDK version: iOS v3.3.3 (release branch)
This is fairly silly, but @1ec5 suggested I post it because it represents 1. a crash that should not happen (regardless), and 2. this issue may be illustrative of a larger async/sync animation problem that exists in core.
Steps to trigger behavior
Try to reset the map to north when also using MGLUserTrackingModeFollowWithCourse.
- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated;
{
if (mapView.userTrackingMode != MGLUserTrackingModeFollowWithHeading && mapView.direction != 0.0)
{
[mapView resetNorth];
}
}Expected behavior
The map direction should oscillate between north and the current course.
Actual behavior
-[MGLMapView resetNorth] triggers a loop, wherein _setDirection:animated: calls Map::cancelTransitions() before starting to a new transition (to north). Eventually this finishes (after 70k steps) and _flyToCamera is called... which crashes:
#0 0x000000010ff385d1 in gcd_queue_item_enqueue_hook ()
#1 0x0000000114400bba in _dispatch_introspection_queue_item_enqueue_hook ()
#2 0x00000001143e8046 in _dispatch_barrier_async_f_slow ()
#3 0x000000010ffb6fcd in -[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3::operator()() const at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:2503
#4 0x000000010ffb6f2d in decltype(std::__1::forward<-[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<-[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3&>(-[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#5 0x000000010ffb6f1c in void std::__1::__invoke_void_return_wrapper<void>::__call<-[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3&>(-[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3&&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:468
#6 0x000000010ffb6d59 in std::__1::__function::__func<-[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3, std::__1::allocator<-[MGLMapView _flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:]::$_3>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1437
#7 0x000000011047f32c in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1817
#8 0x000000011014bbb0 in mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4::operator()() const at /mapbox-gl-native/src/mbgl/map/transform.cpp:617
#9 0x000000011014bb1b in decltype(std::__1::forward<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#10 0x000000011014bb0a in void std::__1::__invoke_void_return_wrapper<void>::__call<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:468
#11 0x000000011014b787 in std::__1::__function::__func<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4, std::__1::allocator<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1437
#12 0x000000011047f32c in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1817
#13 0x00000001101439c1 in mbgl::Transform::cancelTransitions() at /mapbox-gl-native/src/mbgl/map/transform.cpp:639
#14 0x000000011012f136 in mbgl::Map::cancelTransitions() at /mapbox-gl-native/src/mbgl/map/map.cpp:355
#15 0x000000010ff8c393 in -[MGLMapView _setDirection:animated:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:2378
#16 0x000000010ff8c2ee in -[MGLMapView setDirection:animated:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:2372
#17 0x000000010ff866fd in -[MGLMapView resetNorthAnimated:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:1875
#18 0x000000010ff866b0 in -[MGLMapView resetNorth] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:1870
#19 0x000000010feaa95f in -[MBXViewController mapView:regionDidChangeAnimated:] at /mapbox-gl-native/platform/ios/app/MBXViewController.m:77
#20 0x000000010ffa843f in -[MGLMapView notifyMapChange:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:4467
#21 0x000000010ffbc2bd in MBGLView::notifyMapChange(mbgl::MapChange) at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:4903
#22 0x0000000110136373 in mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0::operator()(mbgl::MapChange) const at /mapbox-gl-native/src/mbgl/map/map.cpp:94
#23 0x000000011013630e in std::__1::__invoke<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0&, mbgl::MapChange>(decltype(std::__1::forward<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0&>(fp)(std::__1::forward<mbgl::MapChange>(fp0))), mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0&&&, mbgl::MapChange&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#24 0x00000001101362ee in _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN4mbgl3Map4ImplC1ERNS3_4ViewERNS3_10FileSourceENS3_7MapModeENS3_13GLContextModeENS3_13ConstrainModeENS3_12ViewportModeEE3$_0NS3_9MapChangeEEEEvDpOT_ at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:468
#25 0x0000000110136157 in std::__1::__function::__func<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0, std::__1::allocator<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0>, void (mbgl::MapChange)>::operator()(mbgl::MapChange&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1437
#26 0x000000011014bd1c in std::__1::function<void (mbgl::MapChange)>::operator()(mbgl::MapChange) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1817
#27 0x000000011014bbf7 in mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4::operator()() const at /mapbox-gl-native/src/mbgl/map/transform.cpp:620
#28 0x000000011014bb1b in decltype(std::__1::forward<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#29 0x000000011014bb0a in void std::__1::__invoke_void_return_wrapper<void>::__call<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:468
#30 0x000000011014b787 in std::__1::__function::__func<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4, std::__1::allocator<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1437
#31 0x000000011047f32c in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1817
#32 0x00000001101439c1 in mbgl::Transform::cancelTransitions() at /mapbox-gl-native/src/mbgl/map/transform.cpp:639
#33 0x000000011012f136 in mbgl::Map::cancelTransitions() at /mapbox-gl-native/src/mbgl/map/map.cpp:355
#34 0x000000010ff8c393 in -[MGLMapView _setDirection:animated:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:2378
#35 0x000000010ff8c2ee in -[MGLMapView setDirection:animated:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:2372
#36 0x000000010ff866fd in -[MGLMapView resetNorthAnimated:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:1875
#37 0x000000010ff866b0 in -[MGLMapView resetNorth] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:1870
#38 0x000000010feaa95f in -[MBXViewController mapView:regionDidChangeAnimated:] at /mapbox-gl-native/platform/ios/app/MBXViewController.m:77
#39 0x000000010ffa843f in -[MGLMapView notifyMapChange:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:4467
#40 0x000000010ffbc2bd in MBGLView::notifyMapChange(mbgl::MapChange) at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:4903
#41 0x0000000110136373 in mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0::operator()(mbgl::MapChange) const at /mapbox-gl-native/src/mbgl/map/map.cpp:94
...
#74673 0x0000000110136373 in mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0::operator()(mbgl::MapChange) const at /mapbox-gl-native/src/mbgl/map/map.cpp:94
#74674 0x000000011013630e in std::__1::__invoke<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0&, mbgl::MapChange>(decltype(std::__1::forward<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0&>(fp)(std::__1::forward<mbgl::MapChange>(fp0))), mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0&&&, mbgl::MapChange&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#74675 0x00000001101362ee in _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN4mbgl3Map4ImplC1ERNS3_4ViewERNS3_10FileSourceENS3_7MapModeENS3_13GLContextModeENS3_13ConstrainModeENS3_12ViewportModeEE3$_0NS3_9MapChangeEEEEvDpOT_ at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:468
#74676 0x0000000110136157 in std::__1::__function::__func<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0, std::__1::allocator<mbgl::Map::Impl::Impl(mbgl::View&, mbgl::FileSource&, mbgl::MapMode, mbgl::GLContextMode, mbgl::ConstrainMode, mbgl::ViewportMode)::$_0>, void (mbgl::MapChange)>::operator()(mbgl::MapChange&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1437
#74677 0x000000011014bd1c in std::__1::function<void (mbgl::MapChange)>::operator()(mbgl::MapChange) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1817
#74678 0x000000011014bbf7 in mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4::operator()() const at /mapbox-gl-native/src/mbgl/map/transform.cpp:620
#74679 0x000000011014bb1b in decltype(std::__1::forward<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#74680 0x000000011014bb0a in void std::__1::__invoke_void_return_wrapper<void>::__call<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&>(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4&&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:468
#74681 0x000000011014b787 in std::__1::__function::__func<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4, std::__1::allocator<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_4>, void ()>::operator()() at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1437
#74682 0x000000011047f32c in std::__1::function<void ()>::operator()() const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1817
#74683 0x0000000110149f8c in mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3::operator()(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) const at /mapbox-gl-native/src/mbgl/map/transform.cpp:602
#74684 0x0000000110149656 in decltype(std::__1::forward<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3&>(fp)(std::__1::forward<std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > >(fp0))) std::__1::__invoke<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > >(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3&&&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:416
#74685 0x000000011014962e in mbgl::Update std::__1::__invoke_void_return_wrapper<mbgl::Update>::__call<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > >(mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3&&&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:437
#74686 0x00000001101491b7 in std::__1::__function::__func<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3, std::__1::allocator<mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::__1::function<mbgl::Update (double)>, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&)::$_3>, mbgl::Update (std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >)>::operator()(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1437
#74687 0x000000011014c2ba in std::__1::function<mbgl::Update (std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >)>::operator()(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1817
#74688 0x0000000110143924 in mbgl::Transform::updateTransitions(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > const&) at /mapbox-gl-native/src/mbgl/map/transform.cpp:634
#74689 0x000000011012bb19 in mbgl::Map::render() at /mapbox-gl-native/src/mbgl/map/map.cpp:173
#74690 0x000000010ff794b4 in -[MGLMapView glkView:drawInRect:] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:857
#74691 0x0000000113b2691a in -[GLKView _display:] ()
#74692 0x000000010ff7a990 in -[MGLMapView updateFromDisplayLink] at /mapbox-gl-native/platform/ios/src/MGLMapView.mm:984
#74693 0x0000000112340bf4 in CA::Display::DisplayLinkItem::dispatch() ()
#74694 0x0000000112340abe in CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) ()
#74695 0x000000011167b074 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#74696 0x000000011167ac21 in __CFRunLoopDoTimer ()
#74697 0x000000011163cb11 in __CFRunLoopRun ()
#74698 0x000000011163c0f8 in CFRunLoopRunSpecific ()
#74699 0x000000011842fad2 in GSEventRunModal ()
#74700 0x0000000112464f09 in UIApplicationMain ()
#74701 0x000000010fea587f in main at /mapbox-gl-native/platform/ios/app/main.m:8
#74702 0x000000011443392d in start ()Metadata
Metadata
Assignees
Labels
crashiOSMapbox Maps SDK for iOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Activity
1ec5 commentedon Aug 17, 2016
The stack in #5833 (comment) strongly implicates
-_setDirection:animated:, but-_flyToCamera:edgePadding:…appeared many times further down on the stack as well. (Do you still have the full stack trace saved off somewhere?) The pattern that emerged was contention between-resetNorthAnimated:and-_flyToCamera:…, likely triggered by a premature call tombgl::Map::cancelTransitions()even before checking for camera equality. (-_setVisibleCoordinates:…, which we call for targeted course tracking, even lacks a no-op check.)Here’s a possible scenario that I suspect may lead to a race condition and eventual crash:
-didUpdateLocationWithUserTrackingAnimated:calls-didUpdateLocationWithTargetAnimated:-_setVisibleCoordinates:count:edgePadding:direction:duration:animationTimingFunction:completionHandler:mbgl::Map::cancelTransitions()mbgl::Transform::transitionFinishFnSimilarly:
-didUpdateLocationWithTargetAnimated:subsequently calls-unrotateIfNeededAnimated:-resetNorthAnimated:after a 100-millisecond delay-_setDirection:animated:mbgl::Map::cancelTransitions()The
transitionFinishFnthat-didUpdateLocationWithTargetAnimated:sets doesn’t do much, which explains why we don’t see things immediately grind to a halt as soon as you enter targeted course tracking mode. ButtransitionFinishFnis set by other MGLMapView methods that the developer could call at any time, including:_setCenterCoordinate:edgePadding:zoomLevel:direction:duration:animationTimingFunction:completionHandler:, which among other things gets called by-didUpdateLocationWithUserTrackingAnimated:in untargeted course tracking mode-_setVisibleCoordinates:count:edgePadding:direction:duration:animationTimingFunction:completionHandler:-setCamera:withDuration:animationTimingFunction:completionHandler:, which is often called for state restoration purposes or when the content insets change (due to top or bottom bars resizing, for instance)-_flyToCamera:edgePadding:withDuration:peakAltitude:completionHandler:If any of these methods gets called just before a location update in targeted course tracking mode and a nontrivial completion handler is provided, we have everything we need for the recursion seen here.
As part of #5983, @incanus is swapping some equality checks, which should help to avoid this scenario.
friedbunny commentedon Aug 17, 2016
Recreated the crash: https://gist.github.com/friedbunny/1a9faa1666d0446c7c81206fb96b52c0
I appreciate that Xcode doesn’t try to show tens of thousands of lines in the sidebar:
1ec5 commentedon Aug 17, 2016
OK, so that validates the hypothesis above. To be sure, this particular case can be avoided by putting the call to resetNorth inside a dispatch_async block. Maybe there's a way for the regionDidChange mechanism to put developer- or user-initiated viewport changes inside a dispatch_async block if another animation is already ongoing.
jfirebaugh commentedon Aug 22, 2016
It's not clear to me why the SDK is calling
Map::cancelTransitions()in so many places. The only case whereMap::cancelTransitions()should need to be called is when you want to cancel the current camera operation and not begin a new one. In cases where you want to replace the current camera operation with a new one, the core camera methods handle cancelling the prior operation automatically.jfirebaugh commentedon Aug 22, 2016
I propose we:
cancelTransitions()in the SDK.MapChangeRegionDidChangeAnimated(as a result of cancelling the prior animation) and thenMapChangeRegionWillChangeAnimated(as a result of beginning the new animation). Let's instead just have an unbroken sequence ofMapChangeRegionIsChangingevents. (We can keep the call to thetransitionFinishFnofAnimationOptionsas a means of being notified when the prior animation is abandoned.)incanus commentedon Aug 22, 2016
I agree that we need more core discipline here.
The
MapChangeRegionWillChangeAnimatedandMapChangeRegionDidChangeAnimatedevents are modeled after MapKit, though; specifically,-[MKMapViewDelegate mapView:regionWillChangeAnimated:]and-[MKMapViewDelegate mapView:regionDidChangeAnimated:], which are important for coordinating other UI elements. It is important that they each be sent once at the start & end of a viewport change sequence. HavingMapChangeRegionIsChangingis nice gravy also, and keeps in line with an extra bonus our raster iOS SDK had.1ec5 commentedon Aug 22, 2016
These calls are partly cargo-cult programming, but they stem from #2313 and #3086, in which we were trying to serialize viewport changes and ensure the consistent notifications @incanus refers to above. (The Android SDK did something similar with #2296, and naturally the macOS SDK is canceling transitions too.)
I’m all in favor of an approach where
mbgl::Transformjust does the right thing so the SDK doesn’t have to worry about canceling transitions. Who knows, someday we might even get #3625 along with ponies and rainbows. 🌈If I’m not mistaken, the Android SDK relies on
MapChangeRegionDidChangeAnimatedfor its completion handler analogue. The Android SDK doesn’t usetransitionFinishFnat all./cc @tobrun
1ec5 commentedon Jan 24, 2017
I’m moving this issue to v3.5.0, because a complete fix will require beta testing and possibly changes to mbgl. However, note that #7125 remains on the milestone, and #7724 has landed.
9 remaining items
brunoabinader commentedon Jul 3, 2017
Can we test this again after #9381 got merged?
1ec5 commentedon Jul 3, 2017
Sure, we should double-check this crash. However, I don’t think the infinite recursion is related to #9381;
flyTo()would only be incidental here.friedbunny commentedon Jul 6, 2017
As of 06a0c4a, this still recurses and crashes:
julianrex commentedon Apr 12, 2018
FYI PR #11614 should address the infinite recursion stack crasher (I'm adding a test for this case).
Rejig handling of transition finish lambda. Potentially addresses #5833
Rejig handling of transition finish lambda. Potentially addresses #5833
Rejig handling of transition finish lambda. Potentially addresses #5833
Rejig handling of transition finish lambda. Potentially addresses #5833
Rejig handling of transition finish lambda. Potentially addresses #5833
Rejig handling of transition finish lambda. Potentially addresses #5833
Rejig handling of transition finish lambda. Potentially addresses #5833
julianrex commentedon May 21, 2018
#11614 fixes the stack crasher. But I believe we still need to address the larger issue of how we handle chained transitions (and what happens about cancelling previous ones, and comparing new ones to existing ones).
julianrex commentedon Jun 21, 2018
Closing, since #11614 addresses the crash. Any deeper refactoring is a longer-term issue.
EDIT: /cc @pozdnyakov for visibility on the refactoring we have discussed recently.