ReviewOS

craft-native/craft

fix(ios): settle location promises when Core Location has no callback

#197
Closed glennmichael123 opened this 10 days ago ·
10 days ago

Reproduction

  1. Build an iOS Craft app with geolocation and background location enabled.
  2. In the WebView, call location.getCurrentPosition with high accuracy, zero maximum age, and a 15 second timeout through @stacksjs/mobile.
  3. Run on an iPhone 17 Pro iOS 26.5 simulator with an explicit simulator coordinate.

Actual

The promise never settles. A user-facing location preflight remains unavailable until an app-level timeout intervenes.

Expected

The bridge should resolve with a location or reject with a typed location error within the requested timeout.

Root cause

The generated iOS legacy craft.geolocation.getCurrentPosition registers a callback but no timeout. The compatibility contract delegates to that legacy method, which ignores options and leaves its callback registered indefinitely when Core Location does not invoke either delegate callback. The documented timeout option therefore has no effect on iOS.

Additional permission issue

requestPermission(location) stores locationPermissionCallbackId but does not set locationManager.delegate before requesting authorization and only resolves in locationManagerDidChangeAuthorization. A request made after permission is already granted can remain pending because no authorization transition occurs.

Suggested fix

Use the versioned callback mechanism or add equivalent timeout and cleanup behavior to the legacy bridge. Honor location options, set the manager delegate before authorization requests, and immediately resolve an already-determined authorization status.

Verification

Reproduced in a real compiled simulator app through a Maestro deep-link flow, not only by source inspection.

Sign in to comment on this issue.