Closed turbobuilt closed 6 years ago
That's all the logs you have? Not much to analyze there.
Those are the only logs from the days it was supposed to report but didn't. The actual logs are way to long to post here, so I just posted the last stopBackgroundTask from april 1st, and then the logs from the days it didn't report.
Post the logs to a separate file and link it.
When field-testing, you should use debug: true
so you can hear and see the plugin working (or not working)
Here it is:
[removed for privacy]
The reason I set debug: false, was it seemed like debug:true
prevented the bug from occurring. I may not have waited long enough for the bug to occur though. I can try that again for a week and see if it still works.
Also I force quit the app on the first day of testing, and never reopened it.
First thing's first, review all your event-listeners and make sure you're calling bgGeo.finish(taskId)
2017-03-28 19:58:40.015 ⚠️__45-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 316, remaining time: 4.081271
2017-03-28 19:58:40.016 ⚠️__45-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 317, remaining time: 4.081003
2017-03-28 19:58:40.016 ⚠️__45-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 318, remaining time: 4.080741
2017-03-28 19:58:40.016 ⚠️__45-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 319, remaining time: 4.080566
2017-03-28 19:58:40.016 ⚠️__45-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 320, remaining time: 4.080398
2017-03-28 19:58:40.016 ⚠️__45-[BackgroundTaskManager createBackgroundTask]_block_invoke FORCE KILL BACKGROUND TASK: 314, remaining time: 4.080232
Are you subscribing to the location
event?
You denied "Motion Activity updates" permission?
2017-03-28 19:50:15.248 🎾-[SOMotionDetector startShakeDetection:] sample-rate: 0.2 | M7 DISABLED
No, I am not subscribing to any location event on purpose. I was trying to keep it as bare-bones simple as possible.
I just checked, and yes, I have all motion activity banned on my phone. However, I had another tester who had the same issue, and I don't think he banned motion activity updates. Still, it should work even with said motion updates disabled, right?
It will work without Motion Activity. iOS changes to tracking mode via stationary geofence exit. Your activity-recognition won't be as good and the plugin will consume more battery.
This is interesting:
2017-04-01 20:25:35.901
<+32.84235375,-96.70640444> +/- 2000.00m (speed -1.00 mps / course -1.00) @ 4/1/17, 8:25:35 PM Central Daylight Time
2017-04-01 20:25:35.904
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | distanceFilter: -1.0
╚═══════════════════════════════════════════════════════════
2017-04-01 20:25:35.905 - Acquiring stationary location (3 / 5)
2017-04-01 20:25:35.908 ✅ [BackgroundTaskManager createBackgroundTask]: 98
2017-04-01 20:26:16.066 ⋯-[TSDBLogger db_save] Log committed
2017-04-01 20:26:35.822 ⚠️-[TSLocationManager onStationaryLocationTimeout:]
2017-04-01 20:26:35.823 ✅ Using last-known location <+32.83355556,-96.70142035> +/- 5.00m (speed 0.00 mps / course -1.00) @ 4/1/17, 8:22:07 PM Central Daylight Time
Before you headed out for your 4 mile trip, the plugin created its stationary geofence at this location. Is that where you started your 4 mile trip?
That is the restaurant I was at
So you're saying the plugin failed to detect you leaving that restaurant?
I'm not sure. I didn't plot the points, I just looked at general timestamps
Subscribe to the location
event and simply bgGeo.finish(taskId)
. The plugin needs to check there are no listeners before creating its background-task.
bgGeo.on('location', function(location, taskId) {
bgGeo.finish(taskId);
});
Darn, I think I actually went to the restaurant on saturday night not sunday. But yes, looking through the points, that is indeed the last point that was sent to the server. It didn't record me coming home, or my walk 1 mile out yesterday.
I will add in that code. Any idea why it would work for a few days in the background even without that code?
The plugin has a fail-safe to automatically FORCE KILL BACKGROUND TASK
that you fail to bgGeo.finish
before iOS terminates your app. It's not hurting anything but you don't want to see those.
So I'm confused now. What's the story now?
Saturday 2017-04-01:
Monday 2017-04-03:
Today go on a walk, about 3/4 mile out, not recorded.
I think the plugin thinks you were still in that geofence at the restaurant. I'll have to try and simulate this kind of failure.
Seems about right, but I don't know why it would be doing that. I have rebuilt with debugging enabled, added the location listener and finish(taskId)
, and have enabled m7 tracking. I will see if I get better results.
iOS geofences are handled at the os level. It's up to the os and your network environment to fire them. -- Snet form Gmail Mobile
Do you think desiredAccuracy:100,
combined with disabling motion tracking may be the issue?
No
Have you disabled "Background Fetch" for your app?
I don't think so, but how would I know?
Settings -> Your App -> Background App Refresh
Background App refresh, and all other settings there are enabled. location is set to Always
I have new failure confirmation. I downloaded your sample app https://github.com/transistorsoft/cordova-background-geolocation-SampleApp (ionic 1 branch), and gave it to a tester. The tester had the exact same issue. The sample app was in Debug mode, giving out messages. He noticed that right as he was leaving the restaurant, he got a "stop on terminate restaurant", and that was it. It did not notice him getting home. He had to restart it to re-enenable tracking. The debug image is here: http://turbobuilt.com/IMG_2471.JPG, showing him getting to the restaurant, and the last message just as he is leaving.
looks like the app was configured to stopOnTerminate: true
You'll get a much more pleasant debugging experience if you build the Ionic 2 version. It's the same plugin, just the UI is much much better.
Ok, makes sense. I have asked the other tester to please look at the settings again. I think I just used the ionic 1 version because our app is written in ionic 1.
As for my own testing I have very strange results. For some strange reason, the GPS started saying I was in Rio de Janeiro! It said this for about a day, so I first uninstalled the app we are working on - that didn't help. Then I rebooted and it works now. I'm not sure what happened, but will reinstall our app.
You were probably playing around with "Simulate Location" in XCode.
Ah, you are right! I don't remember doing that, but I see that Rio de Janeiro is selected. You are very on top of things. Thank you!
I've made some changes in the Premium Version that might help with your issue. You used to have access to the private repo, seems you didn't pay the yearly maintenance fee. You'll have to wait some time for the fix to appear here in the public version.
All right, thank you for looking into it.
On Thu, Apr 20, 2017 at 6:49 PM, Chris Scott notifications@github.com wrote:
I've made some changes in the Premium Version that might help with your issue. You used to have access to the private repo, seems you didn't pay the yearly maintenance fee. You'll have to wait some time for the fix to appear here in the public version.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/316#issuecomment-295973457, or mute the thread https://github.com/notifications/unsubscribe-auth/AHakKDwNicez8ynnp7woHFRIMSBCxiVAks5rx-8MgaJpZM4MzaJJ .
Latest stable release has been publish (2.7.1
)
Ok I will try it out. Thanks for letting me know.
Update please.
I have tried to install the latest release (I assume you meant to write 2.7.1 instead of 1.7.1).
I get a build error:
Plugins/cordova-background-geolocation-lt/CDVBackgroundGeolocation.m:35:33: Incompatible block pointer types assigning to 'void (^)(NSString __strong, NSString strong, NSDictionary *strong)' from 'void (^)(NSDictionary *__strong)'
At this code:
bgGeo.geofenceBlock = [self createGeofenceHandler];
which I'm guessing references this code
-(void (^)(NSDictionary *geofenceData)) createGeofenceHandler {
return ^(NSDictionary *geofenceData) {
if (![geofenceListeners count]) {
return;
}
for (NSString *callbackId in geofenceListeners) {
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:geofenceData];
[result setKeepCallbackAsBool:YES];
[self.commandDelegate runInBackground:^{
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
}];
}
};
}
$ cordova platform remove ios
$ cordova platform add ios
rebuild.
Great, it installs now! I will test it over the next several days. I have been busy on other things and had not gotten around to updating this program.
Can this be closed?
Your Environment
cordova -v
): 6.5.0cordova platform ls
): ios 4.3.1Expected Behavior
Plugin should continue reporting locations indefinitely whenever user moves
Actual Behavior
Plugin reports location for several days, maybe a week, then stops reporting locations to server. In my last test, I installed and started the app on Monday. It reported motion fine through Saturday. From Sunday on, it has failed to report when I left the house. I did not open the app or otherwise touch it. On Sunday I went to a restaurant approximately 4 miles away, ate dinner, then left. All locations during this time went unreported.
I have noticed that it is still tracking my location, but it seems that it just isn't triggering a report. The reason this might be the case is that in the privacy part of iOS settings, it shows the purple icon after going on a walk where I was about a mile from my home at the farthest. I'm not sure why it would not be reporting my location change though.
Steps to Reproduce
This is the relevant code:
Context
Debug logs
Did not record my walk yesterday where I went 1 mile out and back (2017-04-03), or trip to place 4 miles away on Sunday (2017-04-02)