-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] Optimize event uploading #6737
[ios] Optimize event uploading #6737
Conversation
@boundsj, thanks for your PR! By analyzing the history of the files in this pull request, we identified @friedbunny, @1ec5 and @bleege to be potential reviewers. |
@@ -489,6 +504,9 @@ - (void)postEvents:(NS_ARRAY_OF(MGLMapboxEventAttributes *) *)events { | |||
} | |||
[strongSelf pushDebugEvent:MGLEventTypeLocalDebug withAttributes:@{MGLEventKeyLocalDebugDescription: @"post", | |||
@"debug.eventsCount": @(events.count)}]; | |||
|
|||
[[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; | |||
_backgroundTaskIdentifier = UIBackgroundTaskInvalid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the background task won’t be invalidated if there was a network error (see L503), which would mean the app continues on in the background until it’s killed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed 7688bcc
This was originally based on the current |
@@ -485,10 +500,15 @@ - (void)postEvents:(NS_ARRAY_OF(MGLMapboxEventAttributes *) *)events { | |||
if (error) { | |||
[strongSelf pushDebugEvent:MGLEventTypeLocalDebug withAttributes:@{MGLEventKeyLocalDebugDescription: @"Network error", | |||
@"error": error}]; | |||
[[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; | |||
_backgroundTaskIdentifier = UIBackgroundTaskInvalid; | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we removed this return
and then enclosed the subsequent pushDebugEvent
in an else
statement, I think we could avoid duplicating the background task invalidation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again. d648594 refactors as you described and squashes this all into a single commit on top of the release branch.
7688bcc
to
d403c77
Compare
Upload any events collected when the app was in use for apps that only have "when in use" location permissions. Also, for all apps, avoid posting event data if there is only a single event.
d403c77
to
d648594
Compare
Upload any events collected when the app was in use for apps that only have "when in use" location permissions. Also, for all apps, avoid posting event data if there is only a single event.
Upload any events collected when the app was in use for apps that only have "when in use" location permissions. Also, for all apps, avoid posting event data if there is only a single event.