Repository navigation
permission_handler_windows: lazily create Geolocator - #1546
Conversation
Independent verification of this fix — including MSIX packaged buildsWe hit the same problem in a password manager, where "this app is using your location" is especially damaging to user trust. We independently arrived at the same root cause and essentially the same fix as this PR before finding it, so treating this as a second data point. Verified on Windows 11 (26300), against a cleared baseline. We first deleted our entries under
Before the change, the MSIX build had an entry with As a control, three stale entries from earlier builds kept their original timestamps (Sep 23 / Sep 30) and were not refreshed by the post-fix launches — so the absence of new entries isn't just the registry failing to update. The MSIX case specifically was raised in #1394 but I couldn't find it verified anywhere, so hopefully this closes that gap. On the safety of removing the subscriptionConfirming from our side as well: ContextThere are currently four open PRs touching this (#1389, #1470, this one, #1568), the oldest from September 2024, and the bug report #1394 has been open since October 2024. This PR looks like the cleanest of them. We're shipping a vendored override in the meantime and would much rather drop it — happy to help with testing if that's useful. |
|
Friendly follow-up now that 0.2.3 is out (2026-11-03): the plugin constructor still subscribes to This PR is small and self-contained, and we've been shipping the equivalent change in production since October — verified on both MSIX-packaged and unpackaged builds (see the comment above). Could it be considered for the next release? If a rebase onto |
721669c to
7bcb94e
Compare
|
Agreed, this still needs fixing. Current I've rebased this PR onto current @mvanbeusekom, could you and the other maintainers review this for the next Windows release? Apps should not appear to access location simply because they depend on |
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #1546 +/- ##
===========================================
- Coverage 89.84% 71.42% -18.42%
===========================================
Files 7 1 -6
Lines 128 35 -93
===========================================
- Hits 115 25 -90
+ Misses 13 10 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The I've opened #1584 to give each tested package its own coverage flag and carry forward its coverage when CI skips that package. Coverage configuration changes will run both suites to establish a complete baseline. Once that fix lands and establishes the baseline on |
|
thanks for the work, should i close #1470 now? |
|
Geolocator is now constructed in IsLocationServiceEnabled (permission_handler_windows_plugin.cpp:144) and still throws winrt::hresult_class_not_registered on Windows 10 1607 LTSB, so the app dies on the first Permission.location.serviceStatus call instead of at startup. IsBluetoothServiceEnabled activates BluetoothAdapter and Radio the same way without a catch, and as a fire_and_forget coroutine any exception there goes straight to winrt::terminate() |
permission_handler_windowscurrently creates a WindowsGeolocatorand subscribes toPositionChangedwhile the plugin is registering. That can make apps appear to access location even when they only depend onpermission_handlerand never request location.This PR removes the eager
Geolocatormember andPositionChangedsubscription.Geolocatoris now created only insideIsLocationServiceEnabled(), so location service-status checks still work without touching the Windows location API during plugin registration.Fixes #983.
Fixes #1394.
Related to #1470 and #1389.
Validation after rebasing onto current
main(2026-11-06):flutter pub get(workspace resolution)dart format --output=none --set-exit-if-changed permission_handler_windows(no changes)flutter analyze --no-pubinpermission_handler_windowsflutter analyze --no-pubinpermission_handler_windows/exampleflutter test --no-pubinpermission_handler(20 tests passed)git diff --check(clean)The Windows package has no unit test suite. A fresh native Windows build is left to this PR's CI; it cannot run on this macOS host. The original C++ fix is unchanged by the rebase, and the package version/changelog now target
0.2.4.Earlier Windows runtime smoke evidence, recorded before this rebase:
0before launch,0after launch)prism_plurality.exe, and location registry entries stayed unchanged (1before launch,1after launch)Pre-launch Checklist
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR does not need version changes.CHANGELOG.mdto add a description of the change.///), or this PR does not need documentation changes.main.dart format .and committed any changes.flutter analyzeand fixed any errors.