When running on the iOS simulator, after granting location permission to 'Always allow' and calling bg.BackgroundGeolocation.start() followed by bg.BackgroundGeolocation.stop(), I stop the app. However, when I try to run the app again on the same simulator, it fails to attach and crashes.
I can run my app on simulator again after i delete and rebuild it again.
Your Environment
Plugin version: 4.16.2
Platform: iOS
OS version: 17.5
Device manufacturer / model: N/A
Flutter info (flutter doctor):
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-x64, locale en-ID)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.95.1)
[✓] Connected device (4 available)
[✓] Network resources
Plugin config:
bg.BackgroundGeolocation.ready(
bg.Config(
debug: !kReleaseMode,
persistMode: bg.Config.PERSIST_MODE_LOCATION,
logLevel: bg.Config.LOG_LEVEL_VERBOSE,
desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
distanceFilter: 10.0,
autoSync: false,
batchSync: true,
backgroundPermissionRationale: bg.PermissionRationale(
title: "Allow {applicationName} to access this device's location even"
" when the app is closed or not in use.",
message:
"This app collects location data to enable recording your trips"
" to work and calculate distance-travelled.",
positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
negativeAction: 'Cancel',
),
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
url: url,
extras: extras,
locationTemplate: '{"latitude":<%= latitude %>,"longitude":<%= longitude %>,"orientation":<%= heading %>,"battery_percentage":<%= battery.level %>,"checkin_timestamps":"<%= timestamp %>"}',
),
)
Expected Behavior
After stopping my app on the simulator, I can run it again without needing to uninstall it first.
Actual Behavior
The simulator crashed and failed to attach after I re-run the app.
Steps to Reproduce
Grant permission to Always Allow
Call bg.BackgroundGeolocation.start() followed by bg.BackgroundGeolocation.stop()
When running on the iOS simulator, after granting location permission to 'Always allow' and calling
bg.BackgroundGeolocation.start()
followed bybg.BackgroundGeolocation.stop()
, I stop the app. However, when I try to run the app again on the same simulator, it fails to attach and crashes.I can run my app on simulator again after i delete and rebuild it again.
Your Environment
flutter doctor
):Expected Behavior
After stopping my app on the simulator, I can run it again without needing to uninstall it first.
Actual Behavior
The simulator crashed and failed to attach after I re-run the app.
Steps to Reproduce
Always Allow
bg.BackgroundGeolocation.start()
followed bybg.BackgroundGeolocation.stop()
Context
Debug logs
Logs
``` Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process: Runner [57557] Triggered by Thread: 0 Last Exception Backtrace: 0 CoreFoundation 0x7ff8004cd521 __exceptionPreprocess + 226 1 libobjc.A.dylib 0x7ff8000837e8 objc_exception_throw + 48 2 Foundation 0x7ff800dff277 -[NSObject(NSKeyValueCoding) dictionaryWithValuesForKeys:] + 0 3 Foundation 0x7ff800dfe18e -[NSObject(NSKeyValueCoding) setValue:forKey:] + 278 4 Runner 0x10da63887 __26-[TSConfig initWithCoder:]_block_invoke + 332 5 Runner 0x10da6236f +[TSConfigBuilder eachProperty:callback:] + 174 6 Runner 0x10da636ed -[TSConfig initWithCoder:] + 245 7 Foundation 0x7ff800e24b4d _decodeObjectBinary + 3329 8 Foundation 0x7ff800e234ef _decodeObject + 163 9 Foundation 0x7ff800e233cf -[NSKeyedUnarchiver decodeObjectForKey:] + 162 10 Foundation 0x7ff800e23776 -[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 379 11 Foundation 0x7ff800d882f9 -[NSCoder __tryDecodeObjectForKey:error:decodeBlock:] + 89 12 Foundation 0x7ff800d891f1 -[NSCoder decodeTopLevelObjectOfClasses:forKey:error:] + 93 13 Foundation 0x7ff800e213cd +[NSKeyedUnarchiver unarchivedObjectOfClasses:fromData:error:] + 124 14 Runner 0x10da656c9 +[TSConfig decodeConfig:] + 253 15 Runner 0x10da633a9 __26+[TSConfig sharedInstance]_block_invoke + 145 16 libdispatch.dylib 0x7ff8001796d8 _dispatch_client_callout + 8 17 libdispatch.dylib 0x7ff80017aaef _dispatch_once_callout + 20 18 Runner 0x10da63316 +[TSConfig sharedInstance] + 46 19 Runner 0x10da740a2 -[TSLocationManager init] + 109 20 Runner 0x10da74020 __35+[TSLocationManager sharedInstance]_block_invoke + 29 21 libdispatch.dylib 0x7ff8001796d8 _dispatch_client_callout + 8 22 libdispatch.dylib 0x7ff80017aaef _dispatch_once_callout + 20 23 Runner 0x10da74001 +[TSLocationManager sharedInstance] + 97 24 Runner 0x10dacfddf -[TSBackgroundGeolocationPlugin init] + 90 (TSBackgroundGeolocationPlugin.m:94) 25 Runner 0x10dacfc52 +[TSBackgroundGeolocationPlugin registerWithRegistrar:] + 189 (TSBackgroundGeolocationPlugin.m:69) 26 Runner 0x10d2c4d46 +[GeneratedPluginRegistrant registerWithRegistry:] + 1286 (GeneratedPluginRegistrant.m:301) 27 Runner 0x10d2c5ff6 AppDelegate.application(_:didFinishLaunchingWithOptions:) + 1974 (AppDelegate.swift:30) 28 Runner 0x10d2c6b77 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 183 29 UIKitCore 0x7ff805cbc5bb -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 297 30 UIKitCore 0x7ff805cbe320 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 4253 31 UIKitCore 0x7ff805cc3ea3 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1241 32 UIKitCore 0x7ff804fe2661 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122 33 UIKitCore 0x7ff8056d7e45 _UIScenePerformActionsWithLifecycleActionMask + 87 34 UIKitCore 0x7ff804fe31bf __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198 35 UIKitCore 0x7ff804fe2c20 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 249 36 UIKitCore 0x7ff804fe3008 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 813 37 UIKitCore 0x7ff804fe2834 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 341 38 UIKitCore 0x7ff804fefe25 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 174 39 UIKitCore 0x7ff805584484 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 865 40 UIKitCore 0x7ff8056f64c3 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 261 41 UIKitCore 0x7ff804fefab4 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 347 42 UIKitCore 0x7ff804dc04db __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.613 + 877 43 UIKitCore 0x7ff804dbee90 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 245 44 UIKitCore 0x7ff804dc0043 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 252 45 UIKitCore 0x7ff805cc26e3 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 672 46 UIKitCore 0x7ff8055b9925 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 353 47 FrontBoardServices 0x7ff807a16db4 -[FBSScene _callOutQueue_didCreateWithTransitionContext:completion:] + 406 48 FrontBoardServices 0x7ff807a4aa0b __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.254 + 279 49 FrontBoardServices 0x7ff807a26a78 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 213 50 FrontBoardServices 0x7ff807a4a705 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke + 328 51 libdispatch.dylib 0x7ff8001796d8 _dispatch_client_callout + 8 52 libdispatch.dylib 0x7ff80017d1e2 _dispatch_block_invoke_direct + 508 53 FrontBoardServices 0x7ff807a7635f __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30 54 FrontBoardServices 0x7ff807a76239 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 188 55 FrontBoardServices 0x7ff807a76387 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 19 56 CoreFoundation 0x7ff800429fb3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 57 CoreFoundation 0x7ff800429ef5 __CFRunLoopDoSource0 + 157 58 CoreFoundation 0x7ff8004296f2 __CFRunLoopDoSources0 + 215 59 CoreFoundation 0x7ff800423e27 __CFRunLoopRun + 919 60 CoreFoundation 0x7ff8004236ad CFRunLoopRunSpecific + 557 61 GraphicsServices 0x7ff8103da08f GSEventRunModal + 137 62 UIKitCore 0x7ff805cc0ad1 -[UIApplication _run] + 972 63 UIKitCore 0x7ff805cc5551 UIApplicationMain + 123 64 Runner 0x10d2c6cdf main + 63 (AppDelegate.swift:12) 65 dyld_sim 0x10e76d3e0 start_sim + 10 66 dyld 0x117dae366 start + 1942 ```