Core Location invoking visit callback with dozens of previously delivered visits from the past

I've been getting duplicate visits sent to my CLLocationManagerDelegate. This is new since iOS 16, I did not see this behavior in iOS 15--the observed effect is a quite severe regression in the behavior of CoreLocation.

Here is what I'm seeing:

  1. The visits have already been delivered
  2. When they're sent 'again', they're sent in dozens of callbacks
  3. When they're sent 'again', they're sent in batches irrespective of app state

I have had a debug app on my phone running since November to capture sysdiagnose for FB12107066. My app simply records data from CoreLocation into a mini Core Data table.

Since November 11th, I have had 3808 visits, but when I do some distinct queries on arrival and departure I get a fraction of that.

Select distinct arrivalDate: 929

Select distinct departureDate: 799

Select distinct arrivalDate + departureDate: 1172

I wrote some logic to attempt to deduplicate and filter out garbage visits that have already been delivered to me, but my filtering isn't bullet proof. This issue has been happening for me on multiple devices since Nov (iOS 16.2 days?).

This happens on an iPhone 13 Pro and an iPad Pro 11-inch (4th gen).

This is a real nasty bug as it also keeps waking my app up in the background when I don't expect it to since the OS is delivering me old / replay visits. :/

  1. Has anyone else seen issue with the Core Location Visit API in iOS 16?
  2. What deduplication and filtering logic did you come up with?

While the issue is affecting me via CoreLocation, I would suspect the same might also occur for anyone using the visits API in SensorKit too.