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_map_flutter] Fix map object regression due to async changes #4171

Merged
merged 10 commits into from
Jun 16, 2023

Conversation

stuartmorgan
Copy link
Contributor

In #4067 I changed several implicitly unawaited futures to await, not noticing that doing so would change the timing on updating fields that were used to compute diffs for future updates. Since the update flow is unawaited at higher levels, this meant that multiple calls to update map objects in rapid succession would compute incorrect diffs due to using the wrong base objects. This fixes that by restoring the old flow using unawaited.

Adds new tests that introduce synthetic awaits into the fake platform interface object and perform multiple updates in a row that should have different base object sets, which fail without the fix.

In order to simplify adding that behavior to the fake, and to pay down technical debt in the unit tests, I replaced the old test fake that is based on method channel interception (which predates the federation of the plugin and is implicitly relying on the method channel implementation from a different package never changing) with a fake platform interface implementation (substantially simplifying the fake).

Fixes flutter/flutter#128042

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@stuartmorgan stuartmorgan requested a review from tarrinneal June 13, 2023 19:44
@ditman
Copy link
Member

ditman commented Jun 13, 2023

because google_maps_flutter_web_integration_tests depends on google_maps_flutter from path, version solving failed.

I think this must have gotten messed up with my federation changes:

https://github.com/flutter/packages/blob/main/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml#L23

There's a circular dependency in the web version of the integration tests so we can render a real map. Maybe that test needs to be moved (actually, "made work") in the core plugin?

@stuartmorgan
Copy link
Contributor Author

There's a circular dependency in the web version of the integration tests so we can render a real map. Maybe that test needs to be moved (actually, "made work") in the core plugin?

I've hacked around it for now, but removing the circular dependency would definitely be better in the longer term.

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

.

@tarrinneal tarrinneal self-requested a review June 15, 2023 19:21
Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

I don't see anything clearly wrong here, but I'm not familiar with the plugin either. Stamped with reservations. If @ditman has time to take a gander, that would be swell.

@stuartmorgan
Copy link
Contributor Author

@ditman I'll plan to land this by EoD tomorrow to get the regression fix out.

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Hit it! (This is so weird, though!)

Comment on lines -376 to +377
await controller._updatePolygons(
PolygonUpdates.from(_polygons.values.toSet(), widget.polygons));
unawaited(controller._updatePolygons(
PolygonUpdates.from(_polygons.values.toSet(), widget.polygons)));
Copy link
Member

Choose a reason for hiding this comment

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

Do you have any idea on what can be improved in the plugin so it can go back to the non-unawaited version? This feels a little bit like the plugin is relying in race conditions all the time to work!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whether the overall design of these enclosing functions not every being awaited can be addressed without breaking changes to clients I'm not sure yet. I believe these could be fixed locally to await by changing the flow of each one to:

  • copy the current value of _foo to oldFoo
  • update _foo (currently done after the unawaited async)
  • do an awaited call using oldFoo instead of _foo as the previous value argument.

I considered doing that in this PR, or leaving a TODO in the code to do it later, but decided that since the only current use of these private methods is from a non-async function that can't await them anyway it wasn't clear that there was a real benefit to doing so. We could certainly revisit though, since I agree it feels a bit weird.

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 16, 2023
@auto-submit auto-submit bot merged commit 754405d into flutter:main Jun 16, 2023
@stuartmorgan stuartmorgan deleted the maps-marker-regression-fix branch June 16, 2023 12:43
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 16, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 16, 2023
flutter/packages@f9314a3...59d93d6

2023-06-16 [email protected] [tool] Add command aliases (flutter/packages#4207)
2023-06-16 [email protected] [google_map_flutter] Fix map object regression due to async changes (flutter/packages#4171)
2023-06-16 [email protected] [url_launcher] Add ignores for deprecated member to test (flutter/packages#4220)
2023-06-15 [email protected] Roll Flutter from 95be76a to b0188cd (10 revisions) (flutter/packages#4221)
2023-06-15 [email protected] [camera_android] Upgrading roboelectric from 4.5 to 4.10.3 (flutter/packages#4018)
2023-06-15 [email protected] [go_router] Fixes bug that GoRouterState in top level redirect doesn'â�¦ (flutter/packages#4173)
2023-06-15 [email protected] [go_router]Updates documentations around GoRouter.of, GoRouter.maybeOf, and BuildContext extension. (flutter/packages#4176)
2023-06-15 [email protected] [tool] Support code excerpts for any .md file (flutter/packages#4212)
2023-06-15 [email protected] [webview_flutter] Add support for limitsNavigationsToAppBoundDomains (flutter/packages#4026)
2023-06-15 [email protected] [webview_flutter][webview_flutter_android] Add android support for handling geolocation permissions (flutter/packages#3795)
2023-06-15 [email protected] [image_picker] add getMedia method (flutter/packages#3892)
2023-06-15 [email protected] [image_picker] getMedia platform implementations (flutter/packages#4175)
2023-06-14 [email protected] Ignore `textScaleFactor` deprecation (flutter/packages#4209)
2023-06-14 [email protected] [pigeon] Enable Obj-C integration tests in CI (flutter/packages#4215)
2023-06-14 [email protected] [flutter_adaptive_scaffold] Support RTL (flutter/packages#4204)
2023-06-14 [email protected] Manual roll Flutter from 09b7e56 to 95be76a (14 revisions) (flutter/packages#4214)
2023-06-14 [email protected] Roll Flutter (stable) from 682aa38 to 796c8ef (5 revisions) (flutter/packages#4213)
2023-06-14 [email protected] Roll Flutter from 353b8bc to 09b7e56 (17 revisions) (flutter/packages#4206)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@jokerttu
Copy link
Contributor

jokerttu commented Aug 17, 2023

@stuartmorgan this issue is still present at example_google_map.dart files used by iOS and Android implementation examples and integration tests; where await is used instead of unawaited causing sync issues.

@stuartmorgan
Copy link
Contributor Author

@stuartmorgan this issue is still present at example_google_map.dart files used by iOS and Android implementation examples and integration tests; where await is used instead of unawaited causing sync issues.

Whoops! Thanks for catching that; I'll get a PR posted shortly.

stuartmorgan added a commit to stuartmorgan/packages that referenced this pull request Aug 17, 2023
Applies the fixes from flutter#4171 to
the minimal ExampleGoogleMaps class used in the Android and iOS
implementation package examples, as they had the same issue.

Also sets up unit testing of the examples in order to add testing of
this fix. The fake is copied directly from the app-facing package, and
the unit tests are slightly modified versions of the tests in the
app-facing package as well.
@stuartmorgan
Copy link
Contributor Author

#4729 will fix the implementation packages.

auto-submit bot pushed a commit that referenced this pull request Aug 18, 2023
Applies the fixes from #4171 to the minimal ExampleGoogleMaps class used in the Android and iOS implementation package examples, as they had the same issue.

Also sets up unit testing of the examples in order to add testing of this fix. The fake is copied directly from the app-facing package, and the unit tests are slightly modified versions of the tests in the app-facing package as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: google_maps_flutter platform-web
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[google_maps_flutter] Map renders already removed markers
4 participants