Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[google_maps_flutter] Add support to request map renderer for Android #6619

Merged

Conversation

jokerttu
Copy link
Contributor

@jokerttu jokerttu commented Oct 25, 2022

This adds support to prefer map renderer for Android.

Added API method initializeWithRenderer for GoogleMapsFlutterAndroid instance to initialize Google Maps SDK with preferred renderer.
Renderer can be initialized only once per Application context and cannot be changed after it is initialized.

New map renderer documentation

Resolves flutter/flutter#114004

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/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin 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.

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

@jokerttu jokerttu requested a review from GaryQian as a code owner October 25, 2022 10:57
@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 to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

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.

@jokerttu jokerttu force-pushed the google_maps_flutter_preferred_renderer branch from 880e0c5 to 384376d Compare October 25, 2022 11:04
@jokerttu jokerttu changed the title [google_maps_flutter_android] Add support to prefer renderer [google_maps_flutter] Add support to prefer renderer Oct 25, 2022
@jokerttu
Copy link
Contributor Author

As this change seems to affect the integration tests of the main plugin at google_maps_flutter/google_maps_flutter/example this is now converted as first phase of the multi-package PR process.

@jokerttu
Copy link
Contributor Author

jokerttu commented Oct 25, 2022

@stuartmorgan
Tests are not runned against this feature at the moment and default preferred renderer is used. The issue is that map renderer initialization can be done only once in application context. And currently tests are driven in single application context. There is not possible way to change the renderer between default, legacy and latest between test runs.

It is as important to run all google_maps_flutter tests against legacy renderer as it is against latest renderer.

One option could be to set preferred renderer for tests by setting MAPS_PREFERRED_RENDERER environment variable for test job at .cirrus.yml#L247
But duplicating the whole android test runs for latest and legacy renderers would not be good option.
Could there be separate task that drives only google_maps_flutter plugin tests with latest renderer separately?

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

For CI tests, I believe we should be able to make a second driver in google_maps_flutter_android/example/test_driver/, and have each driver set a different renderer.

@jokerttu

This comment was marked as outdated.

@jokerttu jokerttu requested review from stuartmorgan and removed request for ditman, GaryQian and cyanglaz October 27, 2022 21:26
@jokerttu jokerttu changed the title [google_maps_flutter] Add support to prefer renderer [google_maps_flutter] Add support to request map renderer for Android Oct 28, 2022
@jokerttu
Copy link
Contributor Author

jokerttu commented Oct 31, 2022

For CI tests, I believe we should be able to make a second driver in google_maps_flutter_android/example/test_driver/, and have each driver set a different renderer.

Seems like drivers are not runned at all on for the Android integration tests; instead integration tests are runned with firebase-test-lab which skips test_driver folder totally and runs tests directly from integration_tests file without drivers.
Implemented approach was legacy way on doing this: flutter/flutter#85224

Moved tests under integration_test folder. Files in this folder are each build and tested separately so those should have separate application contexts as well.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

@GaryQian Could you review the Java part of this?

@jokerttu jokerttu force-pushed the google_maps_flutter_preferred_renderer branch from 410db81 to 975f6cc Compare November 17, 2022 13:26
(LatLngBounds bounds) => bounds != zeroLatLngBounds) ??
(LatLngBounds bounds) =>
bounds != zeroLatLngBounds &&
bounds.northeast != bounds.southwest) ??
Copy link
Contributor Author

@jokerttu jokerttu Nov 17, 2022

Choose a reason for hiding this comment

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

This change is done, as otherwise test fails with latest renderer, as bounds with zero area is given at start.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

This looks good to me from a code standpoint; I'm going to push a change to the branch so that the full Android test suite will run in CI.

@stuartmorgan
Copy link
Contributor

I forgot we can't push to org-repo-owned branches; created #6731 instead.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay here; I forgot that this was just waiting for the results of my test run PR (which passed).

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 7, 2022
@auto-submit auto-submit bot merged commit 93a63b3 into flutter:main Dec 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 8, 2022
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Dec 8, 2022
* 93a63b36e [google_maps_flutter] Add support to request map renderer for Android (flutter/plugins#6619)

* ca3d56973 Roll Flutter from e2fb672 to a570fd2 (15 revisions) (flutter/plugins#6804)

* 51434ec83 [google_maps_flutter] Roll cupertino_icons for compatibility with Dart 3 (flutter/plugins#6807)
@jokerttu jokerttu deleted the google_maps_flutter_preferred_renderer branch December 14, 2022 13:06
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jan 19, 2023
…#116728)

* 93a63b36e [google_maps_flutter] Add support to request map renderer for Android (flutter/plugins#6619)

* ca3d56973 Roll Flutter from e2fb672 to a570fd2 (15 revisions) (flutter/plugins#6804)

* 51434ec83 [google_maps_flutter] Roll cupertino_icons for compatibility with Dart 3 (flutter/plugins#6807)
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
…flutter#6619)

* [google_maps_flutter] support to request a specific map renderer for android

* [google_maps_flutter] Minor fixes to comments and error messages

* [google_maps_flutter] fix linting issues
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App needs tests p: google_maps_flutter platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[google_maps_flutter] Add support to select preferred renderer
2 participants