mapbox/mapbox-navigation-ios

[Bug]: Crash when creating MapboxNavigationService

donaldmanuel opened this issue · 2 comments

Mapbox Navigation SDK version

2.11.0

Steps to reproduce

Running on iPadOS version 16.6

Code is from your example. When we tap the Start Navigation button, the app crashes. We never print "Debug - 2", so it appears to us it's crashing while creating the MapboxNavigationService.

@objc func tappedButton(sender: UIButton) {
    print("tappedButton")
    guard let routeResponse = routeResponse, let navigationRouteOptions = navigationRouteOptions else { return }
    print("Debug - 1")
    // For demonstration purposes, simulate locations if the Simulate Navigation option is on.
    let navigationService = MapboxNavigationService(routeResponse: routeResponse,
                                                    routeIndex: currentRouteIndex,
                                                    routeOptions: navigationRouteOptions,
                                                    customRoutingProvider: NavigationSettings.shared.directions,
                                                    credentials: NavigationSettings.shared.directions.credentials)
    print("Debug - 2")
    let navigationOptions = NavigationOptions(styles: [CustomDayStyle()],
                                              navigationService: navigationService,
                                              
                                              // Replace default NavigationMapView instance with instance that is used in preview mode.
                                              navigationMapView: navigationMapView)
    print("Debug - 3")
    let navigationViewController = NavigationViewController(for: routeResponse,
                                                            routeIndex: currentRouteIndex,
                                                            routeOptions: navigationRouteOptions,
                                                            navigationOptions: navigationOptions)
    print("Debug - 4")
    navigationViewController.delegate = self
    print("Debug - 5")
    navigationViewController.modalPresentationStyle = .fullScreen
    print("Debug - 6")
    
    if let latestValidLocation = navigationMapView.mapView.location.latestLocation?.location {
      print("Debug - 7")
      navigationViewController.navigationMapView?.moveUserLocation(to: latestValidLocation)
      print("Debug - 8")
    }
    
    startButton.isHidden = true
    print("Debug - 9")
    
    // Hide top and bottom container views before animating their presentation.
    navigationViewController.navigationView.bottomBannerContainerView.hide(animated: false)
    print("Debug - 10")
    navigationViewController.navigationView.topBannerContainerView.hide(animated: false)
    print("Debug - 11")
    // Hide WayNameView, FloatingStackView and SpeedLimitView to smoothly present them.
    navigationViewController.navigationView.wayNameView.alpha = 0.0
    print("Debug - 12")
    navigationViewController.navigationView.floatingStackView.alpha = 0.0
    print("Debug - 13")
    navigationViewController.navigationView.speedLimitView.alpha = 0.0
    print("Debug - 14")
    
    present(navigationViewController, animated: false) {
      // Animate top and bottom banner views presentation.
      print("Debug - 16")
      let duration = 1.0
      navigationViewController.navigationView.bottomBannerContainerView.show(duration: duration,
                                                                             animations: {
        print("Debug - 17")
        navigationViewController.navigationView.wayNameView.alpha = 1.0
        print("Debug - 18")
        navigationViewController.navigationView.floatingStackView.alpha = 1.0
        print("Debug - 19")
        navigationViewController.navigationView.speedLimitView.alpha = 1.0
        print("Debug - 20")
      })
      navigationViewController.navigationView.topBannerContainerView.show(duration: duration)
      print("Debug - 21")
    }
    print("Debug - 15")
  }

Expected behavior

Navigation starts.

Actual behavior

App crashes with backtrace:

(lldb)
 
thread #43, name = 'com.mapbox.common.Worker 3', stop reason = signal SIGABRT
  * frame #0: 0x0000000205915578 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000226615118 libsystem_pthread.dylib`pthread_kill + 268
    frame #2: 0x00000001ce780178 libsystem_c.dylib`abort + 180
    frame #3: 0x0000000226553bf8 libc++abi.dylib`abort_message + 132
    frame #4: 0x0000000226543428 libc++abi.dylib`demangling_terminate_handler() + 320
    frame #5: 0x00000001c0379eb4 libobjc.A.dylib`_objc_terminate() + 160
    frame #6: 0x0000000226552fbc libc++abi.dylib`std::__terminate(void (*)()) + 16
    frame #7: 0x0000000226552f60 libc++abi.dylib`std::terminate() + 56
    frame #8: 0x00000001070c33e0 MapboxCommon`__clang_call_terminate + 12
    frame #9: 0x0000000107268608 MapboxCommon`nonstd::expected_lite::expected<std::experimental::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > mapbox::common::parseValue<std::experimental::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(mapbox::feature::value const&) + 296
    frame #10: 0x0000000107238484 MapboxCommon`void mapbox::common::TileStoreOptionsController::set<std::experimental::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(mapbox::common::TileStoreOptionsController::Options&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, mapbox::feature::value&&, std::experimental::optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > mapbox::common::TileStoreOptionsController::Options::*) + 48
    frame #11: 0x000000010724706c MapboxCommon`void mapbox::common::internal::Message<mapbox::common::TileStoreWorker, void (mapbox::common::TileStoreWorker::*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, mapbox::common::TileDataDomain, mapbox::feature::value&&), std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::common::TileDataDomain, mapbox::feature::value> >::invoke<0ul, 1ul, 2ul>(std::__1::integer_sequence<unsigned long, 0ul, 1ul, 2ul>) + 444
    frame #12: 0x000000010712db84 MapboxCommon`mapbox::common::TaskSequence::scheduleTask(unsigned long long, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >)::'lambda'()::operator()() const + 604
    frame #13: 0x0000000107131ec0 MapboxCommon`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, mapbox::common::ThreadedSchedulerBase::makeSchedulerThread(unsigned long, mapbox::base::WeakPtr<mapbox::common::Scheduler>, mapbox::common::ThreadServiceType)::$_0> >(void*) + 1124
    frame #14: 0x000000022660f6b8 libsystem_pthread.dylib`_pthread_start + 148
(lldb)

Is this a one-time issue or a repeatable issue?

repeatable

Udumft commented

Hello, @donaldmanuel! First of all I would suggest you to update to the latest NavSDK version, as 2.11 is quite old. It should not require any code changes on your side. Please give it a try and let me know if that helps

We have a developer who would hit this issue every time. He states moving to v2.15.0 seems to have solved it.