Closed oligazar closed 3 years ago
Hi @oligazar Thank you for opening an issue and your patient;
i am also seeing this bug, using version 1.5.0+1
say you just installed the app. you start it up, the background locator is running, everything is fine. then you stop the app, and wait a few hours. then you try to start it up again, and the app immediately crashes, with that same NSInternalInconsistencyException message in the crash log shown at the top there.
so you uninstall the app, re-install it, and this time it starts up just fine.
Please try the latest beta
version to see if the problem still exist.
@mehdok unfortunately I cannot say exact conditions when the issue happens.
But I was able to catch the issue. It happened in the sendLocationEvent:
method at line
[_callbackChannel invokeMethod:kBCMSendLocation arguments:map];
For some reason FlutterEngine is not ready sometimes when trying to send the message down the _callbackChannel
.
I used isolateId
property of FlutterEngine to figure out if it's running already.
This property will be nil if the engine is not running.
So working solution for me would be :
#pragma mark LocatorPlugin Methods
- (void) sendLocationEvent: (NSDictionary<NSString*,NSNumber*>*)location {
NSString *isolateId = [_headlessRunner isolateId];
if (_callbackChannel == nil || isolateId == nil) {
return;
}
NSDictionary *map = @{
kArgCallback : @([PreferencesManager getCallbackHandle:kCallbackKey]),
kArgLocation: location
};
[_callbackChannel invokeMethod:kBCMSendLocation arguments:map];
}
Please try the latest
beta
version to see if the problem still exist.
still persists in the beta
Am facing the same thing! Have we found any workaround for this?
@oligazar Nice workaround, but I believe it's better to find the real problem (why FlutterEngine has stopped running?). Putting this workaround in the library makes it unrelieble.
Same here. Just in case, here is the log when crashed my app.
(lldb) 2021-06-23 11:44:00.301574+0900 Runner[6022:3393248] 8.0.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
8.0.0 - [Firebase/Analytics][I-ACS023007] Analytics v.8.0.0 started
[Firebase/Crashlytics] Version 8.0.0
8.0.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
8.0.0 - [Firebase/Analytics][I-ACS025036] App Delegate Proxy is disabled
8.0.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
8.0.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
8.0.0 - [Firebase/Analytics][I-ACS023220] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist
*** Assertion failure in -[FlutterEngine sendOnChannel:message:binaryReply:], FlutterEngine.mm:799
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Sending a message before the FlutterEngine has been run.'
*** First throw call stack:
(0x19618586c 0x1ab19ec50 0x19608b000 0x19741f91c 0x104e0ec14 0x10494827c 0x104947f68 0x104948018 0x19c0b5cb4 0x19c0b4fec 0x19c09b670 0x19610149c 0x1961006e4 0x1960fae18 0x1960fa21c 0x1adcc4784 0x198b3aee8 0x198b4075c 0x102b23f94 0x195dba6b0)
libc++abi.dylib: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001c40d5414 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
-> 0x1c40d5414 <+8>: b.lo 0x1c40d5434 ; <+40>
0x1c40d5418 <+12>: pacibsp
0x1c40d541c <+16>: stp x29, x30, [sp, #-0x10]!
0x1c40d5420 <+20>: mov x29, sp
Target 0: (Runner) stopped.
There seems to be a different underlying issue here. When changing iOS permissions from 'Allow only while using App' to 'Always allow' when prompted, the iOS app crashes on startup again and again, even with the above workaround.
It seems to crash on iOS consistently on app startup when permissions are set to 'Always allow'.
Having the same issue, even with the workaround ... I'm using version 1.6.2+1-beta
Same problem.Having the same issue too. iOS 14.6 I'm using version 1.6.2+1-beta
iOS devices. background_locator: 1.6.0+1-beta After tracking longer time in background at the moment of transition to foreground sometimes app crashes.
Fatal Exception: NSInternalInconsistencyException Sending a message before the FlutterEngine has been run. -[BackgroundLocatorPlugin sendLocationEvent:]
AppDelegate
Where
CustomPluginRegistrant
class looks like thisUnfortunatelly this is all I know so far. I'll update when there's more datails.
Any ideas on what might be going on here or how to prevent this from happening?