I’m seeing CLMonitor deliver the same event twice when a CircularGeographicCondition triggers while the app is not running and the system launches it in the background. The two events have the same identifier, state, date and diagnostic data. When the app is in the foreground, I get exactly one event per transition.
I've included a minimum example as an attachment. It creates a CLServiceSession and CLMonitor in application(_:didFinishLaunchingWithOptions:) and observes their events.
Here is a log from a background launch (trimmed to the relevant fields)
15:34:13.742Z App didFinishLaunchingWithOptions: none
15:34:13.784Z CLServiceSession.Diagnostic(all false)
15:34:13.784Z Started monitor
15:34:13.794Z event: identifier: 0DE4B7F8-..., state: satisfied, date: 15:34:13.559Z
15:34:13.795Z event: identifier: 0DE4B7F8-..., state: satisfied, date: 15:34:13.559ZThe two events are identical (including date) and arrive about 1 ms apart. All diagnostic flags on both the event and the service session are false.
What I’ve ruled out / observations
Not a repeated state with new diagnostics. The “Monitoring location changes with Core Location” sample project de-duplicates events whose state matches the previous one, noting that the only new information would be in diagnostics. That doesn’t explain this: the diagnostics are all false, the date is identical, and I don’t see the duplicate in the foreground.
Scales with condition count. With two overlapping conditions, a single boundary crossing produces four events (two per condition) when launched in the background.
The behavior occurs both on a simulator and on a real device
The only reference to this behavior I was able to find is this StackOverflow post which was asked when iOS 6 was the latest
My questions is: Is this duplicate delivery expected when CLMonitor is created in response to a background launch? Or does this indicate I have something set up incorrectly?
0
0
71