fix: request location permission on the main thread so SSIDs are not redacted - #22
Open
eliran-zada-evalon wants to merge 1 commit into
Open
Conversation
CLLocationManager only shows the system authorization prompt and fires its delegate callbacks while the main run loop is running. Requesting authorization in main() before webview.start() meant the prompt never appeared and authorizationStatus stayed NotDetermined, so macOS kept redacting Wi-Fi SSIDs. Move the request into startup() and dispatch it onto the main thread via performSelectorOnMainThread once NSApplication's loop is live. Also short-circuit when already authorized and only show the custom "permission required" dialog on an actual Denied status (not on the transient NotDetermined state). Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the problem?
On macOS 14 Sonoma and later, Location permission is required to read Wi-Fi SSIDs. The app requested authorization in
main()beforewebview.start()was called — i.e. beforeNSApplication's run loop was running.CLLocationManageronly shows the system authorization prompt and delivers its delegate callbacks while the main run loop is active. Because the request happened too early (and the wait loop usedsleep(), which never pumps the run loop), the prompt never appeared,authorizationStatus()stayed atNotDetermined(0), and macOS kept returning redacted SSIDs (n/a, "MAC hidden"). The app also never registered in System Settings → Privacy & Security → Location Services, so the user couldn't grant access manually either.A second, smaller bug: the delegate showed the "Location Services are disabled" dialog for both
DeniedandNotDetermined.NotDeterminedsimply means the user hasn't answered the system prompt yet, so the app's own dialog fired spuriously on first launch.How we fixed it
main()and intostartup(), and dispatch it onto the main thread viaperformSelectorOnMainThread:onceNSApplication's run loop is live. This lets macOS actually present the system prompt and firelocationManagerDidChangeAuthorization:.CLLocationManagerand its delegate alive for the process lifetime (module-level references) so callbacks aren't lost to GC.AuthorizedAlways/AuthorizedWhenInUse.Deniedstatus — not on the transientNotDeterminedstate.How we validated the fixes
.appbundle (which carriesNSLocationWhenInUseUsageDescription) via PyInstaller and launched it; the app now triggers the system location prompt / appears in Location Services, after which real SSIDs populate.python -mdev entry point still behaves correctly (no spurious dialog on first launch).Notes
.app(theInfo.plistusage-description key); the unbundledpython -mdev run cannot be granted location on Sonoma+. This PR makes the in-app request flow correct for the bundle.Made with Cursor