[geolocator_apple] Crash if listen/cancel is executed in quick succession
The onDidAuthorizationChanged is executed by iOS somewhen afer CLLocationManager is created in onListenWithArguments.
If the the subscription is canceled in the meantime _eventSink (onCancelWithArguments) is set to nil leading to accessing _eventSink when already nil (BAD_ACCESS crash).
Pre-launch Checklist
- [x] I made sure the project builds.
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I updated
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes. - [x] I updated
CHANGELOG.mdto add a description of the change. - [x] I updated/added relevant documentation (doc comments with
///). - [x] I rebased onto
main. - [x] I added new tests to check the change I am making, or this PR does not need tests.
- [x] I made sure all existing and new tests are passing.
- [x] I ran
dart format .and committed any changes. - [x] I ran
flutter analyzeand fixed any errors.
Dear @mkurz-it,
Thanks for your contribution. Is there an issue related to this PR? I tried to reproduce this in "main" but I could not make it crash (although I can see that it potentially could crash from code :)).
Kind regards
Hi @TimHoogstrate
Thanks for taking your time.
... Is there an issue related to this PR? I tried to reproduce this in "main" but I could not make it crash (although I can see that it potentially could crash from code :)).
There is no open issue. We are using your package in our APP and it crashed. When analyzing the problem the fixed code was the cause.
FYI: It did not crash on every startup (so every 5-10 starts). It will crash if you cancel the subscription quickly after subscription. Actually before iOS called onDidAuthorizationChanged (is called asynchronously by the OS).
Best regards,
Michael
Dear @mkurz-it,
It looks good, but can you "split/update" the PR in geolocator_apple and remove/revert the "geolocator" App Facing Package changes, as they are not needed. It will be updated automatically as a patch to users. If you need some help, ping us.
Kind regards,