background_locator icon indicating copy to clipboard operation
background_locator copied to clipboard

Example app continues to log positions after having clicked "stop"

Open gianmarcocalbi opened this issue 4 years ago • 9 comments

Hello!

As you may notice from the attached screenshot, even though I stopped the example app at 14:58, it continued logging positions.

Oddly the interval between these unexpected positions is either 3 or 6 minutes, much bigger than before clicking stop.

IMAGE 2021-01-05 15:26:48

Thank you

gianmarcocalbi avatar Jan 05 '21 14:01 gianmarcocalbi

Hi @gianmarcocalbi Thank you for opening an issue

  • Is this only happens on iOS?
  • Is this the example app? If not please share some code.
  • Any logs and suggestions would be appreciated.

mehdok avatar Jan 06 '21 05:01 mehdok

Hello, thanks for the reply.

  • ATM I can try only on iOS (I cannot manage to have android emulator working on Apple Silicon)
  • Yes, this is the example app
  • here is another execution with logs

Console logs

flutter: Initializing...
flutter: Initialization done
flutter: Running false
flutter: ***********Init callback handler
flutter: 1
flutter: 1 location in dart: LocationDto{latitude: 37.33181965, longitude: -122.03043332, accuracy: 10.0, altitude: 0.0, speed: 3.59, speedAccuracy: 0.0, heading: -1.0, time: 1609920934124.101, isMocked: false}
flutter: 1 location in dart: LocationDto{latitude: 37.33022215, longitude: -122.02779626, accuracy: 5.0, altitude: 0.0, speed: 3.57, speedAccuracy: 0.0, heading: 270.36, time: 1609924421631.161, isMocked: false}
flutter: 3 location in dart: LocationDto{latitude: 37.33022235, longitude: -122.02783534, accuracy: 5.0, altitude: 0.0, speed: 3.59, speedAccuracy: 0.0, heading: 272.41, time: 1609924422573.866, isMocked: false}
flutter: 4 location in dart: LocationDto{latitude: 37.33022218, longitude: -122.02787449, accuracy: 5.0, altitude: 0.0, speed: 3.62, speedAccuracy: 0.0, heading: 273.21, time: 1609924423630.447, isMocked: false}
flutter: ***********Dispose callback handler
flutter: 5 location in dart: LocationDto{latitude: 37.33020881, longitude: -122.02514114, accuracy: 10.0, altitude: 0.0, speed: 3.57, speedAccuracy: 0.0, heading: 88.04, time: 1609924693692.388, isMocked: false}
flutter: 6 location in dart: LocationDto{latitude: 37.32873847, longitude: -122.01980584, accuracy: 10.0, altitude: 0.0, speed: 3.68, speedAccuracy: 0.0, heading: 179.29, time: 1609924846685.1511, isMocked: false}

iOS system logs

Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.corelocation.CoreLocationVanillaWhenInUseAuthPromptPlugin): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.corelocation.CoreLocationVanillaWhenInUseAuthPromptPlugin): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.CoreMLModelSecurityService): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.CoreMLModelSecurityService): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.DocumentManagerCore.Downloads): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.DocumentManagerCore.Downloads): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FileProvider.ArchiveService): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FileProvider.ArchiveService): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FontServices.FontProviderLoader): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FontServices.FontProviderLoader): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FontServices.GSFontServices): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FontServices.GSFontServices): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FontServices.UserFontManager): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.FontServices.UserFontManager): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.MTLCompilerService): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.MTLCompilerService): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.StreamingUnzipService): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.StreamingUnzipService): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.backboard.display.archive): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.backboard.display.archive): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.externalaccessory.WACEAService): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.externalaccessory.WACEAService): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.intents.intents-helper): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.intents.intents-helper): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.textkit.nsattributedstringagent): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.textkit.nsattributedstringagent): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.uifoundation-bundle-helper): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.uifoundation-bundle-helper): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.xpc.launchd.domain.pid.CoreLocationVanillaWhenInUseAuthPromptPlugin.5897): Failed to bootstrap path: path = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit, error = 2: No such file or directory
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.xpc.launchd.domain.pid.CoreLocationVanillaWhenInUseAuthPromptPlugin.5897): Failed to bootstrap path: path = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim, error = 2: No such file or directory
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.CallKit.CallDirectoryMaintenance): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.CallKit.CallDirectoryMaintenance): Unknown key for Boolean: EnablePressuredExit
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.CallKit.CallDirectory): Unknown key for Boolean: EnableTransactions
Jan  6 10:13:39 gdev-mac com.apple.CoreSimulator.SimDevice.68D3FFB8-E9FD-4A6B-AC7C-D6ED44CDCBCA[1008] (com.apple.CallKit.CallDirectory): Unknown key for Boolean: EnablePressuredExit

gianmarcocalbi avatar Jan 06 '21 09:01 gianmarcocalbi

@gianmarcocalbi I need help. I am getting below error: [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)

siva563 avatar Jan 06 '21 19:01 siva563

@gianmarcocalbi Thank you for detailed logs, I'll try to replicate this error and will share the result with you;

mehdok avatar Jan 07 '21 06:01 mehdok

I am facing the same issue, were you able to resolve this?

hiteshkumartank avatar Feb 10 '21 08:02 hiteshkumartank

I can also confirm that the callback is still called on iOS, although it seems to be in a way longer interval than when it's normally active. And also the location icon is not filled anymore, so I guess it is not actively monitoring the location but still sending something though?

wwwdata avatar Feb 22 '21 08:02 wwwdata

Hi @medhok,

We're using this plugin in our app and we're facing this issue too.

We'd like to release this in iOS but with this plugin being unable to work under iOS correctly we cann't do that.

Is there any solution for this?

Cheers,

francipvb avatar May 07 '21 01:05 francipvb

Hm, I was just reading through the code a bit. What is basically confusing me a bit is this method here: https://github.com/rekab-app/background_locator/blob/132b5b9daba8140d1e1afc7e632425c9dc9b0956/ios/Classes/BackgroundLocatorPlugin.m#L190

Docs: https://developer.apple.com/documentation/corelocation/cllocationmanager/1423531-startmonitoringsignificantlocati

If you start this service and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives. In such a case, the options dictionary passed to the application(:willFinishLaunchingWithOptions:) and application(:didFinishLaunchingWithOptions:) methods of your app delegate contains the key location to indicate that your app was launched because of a location event.

If I understand this correctly, this would also wake the app up when the location changed significantly and then it could be that the app keeps running in the background and we might receive those location updates?

I could not find the corresponding stopMonitoringSignificantLocationChanges method call anywhere in the code, or is it not necessary to also call this when stopping the location tracking?

At least the documentation here also says, this should be called to deactivate the start call

Use this method to stop the delivery of location events that was started using the startMonitoringSignificantLocationChanges() method.

@mehdok could this be something that causes the bug? I am not a CoreLocation expert on iOS, just guessing a bit.

wwwdata avatar May 11 '21 19:05 wwwdata

But I also don't understand this. The location region monitoring is basically always registered, no matter what, when the app is closed?

https://github.com/rekab-app/background_locator/blob/132b5b9daba8140d1e1afc7e632425c9dc9b0956/ios/Classes/BackgroundLocatorPlugin.m#L65-L67

Does that code mean even if the recording was stopped, but then obviously we still have a _lastLocation set, it will set up region monitoring and when the app is relaunched, continue the location tracking? I didn't really understand which part of the code would prevent that if the tracking was stopped. Shouldn't the applicationWillTerminate method also check if the service is still enabled or not? And only register the region monitoring if the service is enabled?

wwwdata avatar May 11 '21 20:05 wwwdata