-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[google_maps_flutter] Fixes exception when dispose is called while asynchronous update from didUpdateWidget is executed #9227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
I'm not sure how I would go about writing a test to make sure that the call from async code is not executed if the widget state has been disposed. |
Why would it be non-deterministic in a test? |
de91b6d
to
d60e4fc
Compare
@stuartmorgan-g I've added tests covering both the I have also expanded the mount check around the call to If the mount check around I was also wondering if there is a technical reason the tile overlays are updated only after the controller is available and not set in the |
d60e4fc
to
a1dbb38
Compare
This PR fixes an exception in Google Maps Flutter which occurs when dispose is called while asynchronous code is executed from didUpdateWidget.
flutter/flutter#43785
I've done the work in 2 commits, the first one just used mount checks on after each awaited retrieval of the controller.
The second reuses the controller to limit the number of awaited async calls.
I am a little unsure of the expected execution order of all the unawaited futures which update the controller in regards to whether dispose could still be called in between their executions.
Testing locally I haven't been able to reproduce the exception with a single awaited controller.
I bumped the version 2.12.2 as no feature behaviour has changed.
No new tests in this PR, I'm not sure that you can test this change using widget tests.
Existing test coverage ensures that the values are still being updated correctly.
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Code Sample
This sample app can be used to trigger the error, just repeatedly tapping the button at the bottom of the screen to reload the map. I did the testing in Chrome using the google_maps_flutter_web example project and the javascript key in web/index.html
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3