background_locator: iOS 14+ crash on app startup when location set to 'Always Allow'
Using release 1.6.3
When changing iOS permissions from 'Allow only while using App to ‘Always allow’ when prompted, the iOS app crashes on startup.
At first, the app launches fine with no issues for a few hours after setting the location permissions to ‘Always allow’. Thereafter the app seems to crash consistently on app startup.
Note: Setting the location permissions back to ‘Only while using the app’ removes the crash and the app then functions fine again.
Here are some error logs:
Fatal Exception: NSInternalInconsistencyException
Sending a message before the FlutterEngine has been run.
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x1a7dd9754 __exceptionPreprocess
1 libobjc.A.dylib 0x1bc8a07a8 objc_exception_throw
2 CoreFoundation 0x1a7cdb3f8 -[CFPrefsSearchListSource addManagedSourceForIdentifier:user:]
3 Foundation 0x1a90af714 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 Flutter 0x10288115c (Missing)
5 background_locator 0x10268b8fc (Missing)
6 background_locator 0x10268c864 (Missing)
7 background_locator 0x10268c638 (Missing)
8 background_locator 0x10268ba50 (Missing)
9 Flutter 0x10288d15c (Missing)
10 Runner 0x100e97674 AppDelegate.application(_:didFinishLaunchingWithOptions:) + 24 (AppDelegate.swift:24)
11 Runner 0x100e977a8 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) (<compiler-generated>)
12 UIKitCore 0x1aa7c37a8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
13 UIKitCore 0x1aa7c523c -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
14 UIKitCore 0x1aa7cb388 -[UIApplication _runWithMainScene:transitionContext:completion:]
15 UIKitCore 0x1a9e1ec98 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
16 UIKitCore 0x1aa387f58 _UIScenePerformActionsWithLifecycleActionMask
17 UIKitCore 0x1a9e1f830 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
18 UIKitCore 0x1a9e1f238 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
19 UIKitCore 0x1a9e1f640 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
20 UIKitCore 0x1a9e1ee7c -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
21 UIKitCore 0x1a9e273c0 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
22 UIKitCore 0x1aa295970 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
23 UIKitCore 0x1aa3a0d68 _UISceneSettingsDiffActionPerformChangesWithTransitionContext
24 UIKitCore 0x1a9e270b8 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
25 UIKitCore 0x1a9c4efa0 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
26 UIKitCore 0x1a9c4d920 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
27 UIKitCore 0x1a9c4ebc8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
28 UIKitCore 0x1aa7c9528 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
29 UIKitCore 0x1aa2befd0 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
30 FrontBoardServices 0x1b736b5d8 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:]
31 FrontBoardServices 0x1b7396d44 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.200
32 FrontBoardServices 0x1b737a6a4 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
33 FrontBoardServices 0x1b7396a0c __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke
34 libdispatch.dylib 0x1a79c681c _dispatch_client_callout
35 libdispatch.dylib 0x1a79ca30c _dispatch_block_invoke_direct
36 FrontBoardServices 0x1b73befa0 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
37 FrontBoardServices 0x1b73bec30 -[FBSSerialQueue _targetQueue_performNextIfPossible]
38 FrontBoardServices 0x1b73bf184 -[FBSSerialQueue _performNextFromRunLoopSource]
39 CoreFoundation 0x1a7d539e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
40 CoreFoundation 0x1a7d538e4 __CFRunLoopDoSource0
41 CoreFoundation 0x1a7d52be8 __CFRunLoopDoSources0
42 CoreFoundation 0x1a7d4cbc8 __CFRunLoopRun
43 CoreFoundation 0x1a7d4c360 CFRunLoopRunSpecific
44 GraphicsServices 0x1bf38a734 GSEventRunModal
45 UIKitCore 0x1aa7c7584 -[UIApplication _run]
46 UIKitCore 0x1aa7ccdf4 UIApplicationMain
47 Runner 0x100e97a70 main + 15 (AppDelegate.swift:15)
48 libdyld.dylib 0x1a7a08cf8 start
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 21
works. @mehdok you’re cool! thank you, you saved my project 😀
Everything works fine for me, on all devices.
@mehdok my log: 2021-07-19 16:15:08.207538+0300 Runner[59446:6431906] [TSBackgroundFetch load]: ( ) 2021-07-19 16:15:08.207923+0300 Runner[59446:6431906] [TSBGAppRefreshSubscriber load]: { } 2021-07-19 16:15:08.673375+0300 Runner[59446:6431906] Metal API Validation Enabled 2021-07-19 16:15:09.054330+0300 Runner[59446:6431906] *** Assertion failure in -[FlutterEngine sendOnChannel:message:binaryReply:], FlutterEngine.mm:799 2021-07-19 16:15:09.075527+0300 Runner[59446:6431906] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Sending a message before the FlutterEngine has been run.’ *** First throw call stack: ( 0 CoreFoundation 0x00007fff20422fba __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff20193ff5 objc_exception_throw + 48 2 CoreFoundation 0x00007fff20422de3 +[NSException raise:format:] + 0 3 Foundation 0x00007fff207748e7 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191 4 Flutter 0x0000000100c5d006 -[FlutterEngine sendOnChannel:message:binaryReply:] + 544 5 background_locator 0x0000000100b05db0 -[BackgroundLocatorPlugin invokeMethod:arguments:] + 96 6 background_locator 0x0000000100b0780c -[DisposePluggable onServiceDispose] + 268 7 background_locator 0x0000000100b0751e -[BackgroundLocatorPlugin removeLocator] + 910 8 background_locator 0x0000000100b05fed -[BackgroundLocatorPlugin application:didFinishLaunchingWithOptions:] + 301 9 Flutter 0x0000000100c6aefd -[FlutterPluginAppLifeCycleDelegate application:didFinishLaunchingWithOptions:] + 296 10 Runner 0x00000001000d2ac2 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtF + 466 11 Runner 0x00000001000d2d03 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 211 12 UIKitCore 0x00007fff246bd6f1 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232 13 UIKitCore 0x00007fff246bf33b -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 4046 14 UIKitCore 0x00007fff246c4d63 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1237 15 UIKitCore 0x00007fff23ce629b -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122 16 UIKitCore 0x00007fff24272726 _UIScenePerformActionsWithLifecycleActionMask + 88 17 UIKitCore 0x00007fff23ce6dad __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198 18 UIKitCore 0x00007fff23ce686e -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 474 19 UIKitCore 0x00007fff23ce6bda -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 818 20 UIKitCore 0x00007fff23ce646f -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345 21 UIKitCore 0x00007fff23cee6d8 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 178 22 UIKitCore 0x00007fff2417c77d +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 871 23 UIKitCore 0x00007fff2428f60e _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 246 24 UIKitCore 0x00007fff23cee3de -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 361 25 UIKitCore 0x00007fff23b117d5 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 797 26 UIKitCore 0x00007fff23b1024e -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253 27 UIKitCore 0x00007fff23b1140e -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 208 28 UIKitCore 0x00007fff246c3203 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 508 29 UIKitCore 0x00007fff241a4ab4 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 358 30 FrontBoardServices 0x00007fff25a1b40b -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 398 31 FrontBoardServices 0x00007fff25a43e55 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 102 32 FrontBoardServices 0x00007fff25a28f12 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209 33 FrontBoardServices 0x00007fff25a43b28 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 352 34 libdispatch.dylib 0x0000000103d6274e _dispatch_client_callout + 8 35 libdispatch.dylib 0x0000000103d65656 _dispatch_block_invoke_direct + 295 36 FrontBoardServices 0x00007fff25a695d0 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 30 37 FrontBoardServices 0x00007fff25a692b6 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 433 38 FrontBoardServices 0x00007fff25a6977b -[FBSSerialQueue _performNextFromRunLoopSource] + 22 39 CoreFoundation 0x00007fff20390ede CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 40 CoreFoundation 0x00007fff20390dd6 __CFRunLoopDoSource0 + 180 41 CoreFoundation 0x00007fff2039029e __CFRunLoopDoSources0 + 242 42 CoreFoundation 0x00007fff2038a9f7 __CFRunLoopRun + 875 43 CoreFoundation 0x00007fff2038a1a7 CFRunLoopRunSpecific + 567 44 GraphicsServices 0x00007fff2b874d85 GSEventRunModal + 139 45 UIKitCore 0x00007fff246c14df -[UIApplication _run] + 912 46 UIKitCore 0x00007fff246c639c UIApplicationMain + 101 47 Runner 0x00000001000d2eab main + 75 48 libdyld.dylib 0x00007fff2025abbd start + 1 ) libc++abi: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Sending a message before the FlutterEngine has been run.’ CoreSimulator 757.5 - Device: iPhone 12 Pro Max (8BC45FE7-7ACE-45CE-801C-BC9FC8EA0981) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 12 Pro Max terminating with uncaught exception of type NSException (lldb)
How to reproduce the bug
https://user-images.githubusercontent.com/15630163/126048625-d0275c41-46be-4ce5-91a7-368f835ad371.mov
Environment: mac os 11.4 flutter 2.2.3 ios emulator 12 pro max 14.5 xcode 12.5.1 android studio 4.2.2