Skip to content
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

[google_maps_flutter] improvements to google maps state handling #8431

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

illuminati1911
Copy link

@illuminati1911 illuminati1911 commented Jan 15, 2025

  • Added checks to Google Map Controller for map mounted state. This is done to prevent PlatformException when calling methods of already unmounted map instance.
  • Improved handling (creation/removal) of tile overlays

Related issue:
flutter/flutter#43785

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@illuminati1911 illuminati1911 changed the title feat: add mounted check to google map controller [google_maps_flutter] add mounted check to google map controller Jan 17, 2025
@illuminati1911 illuminati1911 force-pushed the feat/google-map-controller-mounted-check branch 2 times, most recently from f2cf468 to a20b7f7 Compare January 20, 2025 02:42
@@ -469,7 +469,6 @@ class _GoogleMapState extends State<GoogleMap> {
this,
);
_controller.complete(controller);
unawaited(_updateTileOverlays());
Copy link
Author

@illuminati1911 illuminati1911 Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this as it seems to be unnecessary when the missing widget.tileOverlays is added to the google map. Also this may have cause this issue:
flutter/flutter#43785 (comment)

@illuminati1911 illuminati1911 force-pushed the feat/google-map-controller-mounted-check branch from b8ad73b to 254f58f Compare January 23, 2025 06:36
@jokerttu jokerttu changed the title [google_maps_flutter] add mounted check to google map controller [google_maps_flutter] improvements to google maps state handling Jan 23, 2025
@illuminati1911 illuminati1911 force-pushed the feat/google-map-controller-mounted-check branch 2 times, most recently from 6f39abd to 0113dab Compare January 24, 2025 07:06
@illuminati1911 illuminati1911 marked this pull request as ready for review January 24, 2025 07:25
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

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. 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.

@ChristianEdwardPadilla
Copy link
Contributor

FYI this might help with another issue: flutter/flutter#115283

Which has an older attempted fix PR that you might be able to glean something useful from:
#4281

@illuminati1911 illuminati1911 force-pushed the feat/google-map-controller-mounted-check branch from 0113dab to 5f4c4f3 Compare February 4, 2025 06:10
@stuartmorgan
Copy link
Contributor

Could you elaborate on the goal of this PR? The issue the PR links to appears to be about a case where an internal callback was being run against an unmounted map, and the issue linked in the comment above is also about callbacks, meaning in these cases it's not clear that plugin clients are involved. This PR, however, is putting exceptions on client-facing APIs. Isn't the way for clients to not have this problem just to not call the methods after unmounting the widget, which they can already do?

Is the goal just to improve the error messages? If so, it seems like these should be Errors, not Exceptions, as it seems like a programming error to be calling them in the first place.

@@ -529,6 +529,11 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
.toList(),
);

if (_tileOverlays[creationId] == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the issue this change corresponds to? It's not at all clear to me what this is fixing, or why it is necessary specifically for tile overlays and no other types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants