Significant Disparity in Event Frequency Between CLCircularRegion (Legacy) and CLMonitor (iOS 17+) Geofencing APIs

1. The Inquiry

Hello,

I have been implementing a background geofencing feature and, during testing, I found a significant numerical difference in event callback frequency between the older CLCircularRegion API and the newer CLMonitor API (CLMonitor.CircularGeographicCondition), introduced in iOS 17.

My testing was strictly conducted using the "Always Allow" location permission (requestAlwaysAuthorization()). I used both APIs in parallel under identical geofencing conditions and within the same implementation environment. Since a clear difference persists in the data, I suspect this may stem from structural differences in the internal mechanisms of the two APIs rather than an implementation error on my part.


2. Environment and Implementation Details (Proof of Integrity)

I have ensured that my implementation adheres to Apple's guidelines and uses modern Swift concurrency features.

A. Development Environment and Permissions

  • iOS Version: iOS 18.x and later
  • Xcode Version: Version 17A400 (Version 26.0.1)
  • Location Authorization: Always permission obtained.
  • Background Mode: Location updates is configured correctly in Info.plist.

B. CLMonitor Initialization and Lifecycle

I implemented robust lifecycle management to ensure CLMonitor is stable and persists correctly:

  • Initialization: I performed CLLocationManager object allocation and related service setup (e.g., CLServiceSession set to always) within the call stack frame of didFinishLaunchingWithOptions.
  • Monitor Management: I use an Actor-based Singleton pattern to guarantee that only a single CLMonitor instance is used application-wide.
  • Event Monitoring: Following initialization, I allocated a background Task containing the for try await event in await monitor.events loop. This Task is explicitly managed to persist in the background until the application is terminated, ensuring continuous event listening.

C. Registration Limit Management

I manage both APIs to ensure they never exceed the recommended maximum of 20 simultaneously monitored regions/conditions. My logic removes the oldest item (LRU) when the limit is reached.

The average registration counts during the test period were highly similar:

ComponentAverage Registered Count
CLCircularRegion count7.02
CLMonitor.CircularGeographicCondition count7.04
  • This confirms that registration count is not the cause of the event frequency difference.

3. Data-Based Observation

The test data (bubble_test_data_for_apple_forum.csv) records the event callbacks for both APIs under identical conditions:

ComponentTotal CountPercentage of All Events (%)
CLCircularRegion Delegate Total Calls61783.56%
CLMonitor Event Total Fires12216.44%
Overall Total Count739100%

A. Key Findings

  1. CLCircularRegion Operability: 617 calls confirm that core implementation factors (permissions, background setup, etc.) are functioning correctly.
  2. Disparity in Frequency: Despite running in parallel, the CLMonitor event count (122) is approximately 1/5th the frequency of the CLCircularRegion calls (617).
  3. Efficiency per Registration: CLCircularRegion averaged ~0.86 calls per registered item, while CLMonitor averaged only ~0.17 calls per registered item.

4. Questions for Apple Engineering

Based on the robust implementation and the data presented, I request a review of the following potential differences between the APIs:

  1. Internal Mechanism Differences: Are there structural differences in how CLCircularRegion and CLMonitor.CircularGeographicCondition process and schedule geofencing event callbacks? For instance, do they differ in terms of battery optimization priority, event batching, or internal throttling mechanisms?
  2. CLMonitor Event Ratio: Is the phenomenon where CLMonitor records a significantly lower ratio of events compared to CLCircularRegion an intended behavior, or could this be indicative of a specific environmental factor that affects the newer API differently?

Thank you for your time and assistance.

Significant Disparity in Event Frequency Between CLCircularRegion (Legacy) and CLMonitor (iOS 17+) Geofencing APIs
 
 
Q