Skip to content

Conversation

@jokerttu
Copy link
Contributor

@jokerttu jokerttu commented Feb 4, 2025

This PR contains platform implementations for the ground overlays support (#8432).

Linked issue: flutter/flutter#26479

Pre-launch Checklist

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

@jokerttu jokerttu force-pushed the feat/google_maps_flutter_ground_overlay_support_platform_impl branch from a859a4d to 43522ae Compare February 5, 2025 17:15
@jokerttu jokerttu marked this pull request as ready for review February 5, 2025 17:37
@stuartmorgan-g stuartmorgan-g added triage-ios Should be looked at in iOS triage triage-android Should be looked at in Android triage triage-web Should be looked at in web triage labels Feb 5, 2025
@ditman
Copy link
Member

ditman commented Feb 5, 2025

Looking at web stuff!

@reidbaker reidbaker requested a review from ash2moon February 6, 2025 20:20
@stuartmorgan-g stuartmorgan-g removed triage-ios Should be looked at in iOS triage triage-android Should be looked at in Android triage labels Feb 6, 2025
Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Android and iOS LGTM; I did a full review of both. Please wait for @ditman's review covering web before landing though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The return and the parameters should get nullability annotations.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@NonNull

Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be pulled out of the other file into a test helper file, rather than duplicating the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to TestImageUtils.java

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does nullable instancetype not work? (I can never remember the exact set of cases where nullable doesn't 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.

I removed the nullable annotation from these instance initialisations as they do not explicitly return nil.
There isn't any handling for null instances on code either.
I would assume that self = [super init]; returns instance, and if not, something is really broken.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: If you make locals for groundOverlay.position and groundOverlay.bounds just before the if block, and use the locals everywhere after that (including the conditions), you won't need most of the force-unwraps below.

@stuartmorgan-g
Copy link
Collaborator

(@ash-google Feel free to review as well, I just had already looked over the mobile platforms in the main PR so I went ahead and did a review here to cover those.)

Copy link
Contributor

Choose a reason for hiding this comment

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

This should have an assertion message indicating why it is required or at least log an error saying that width is required.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract these constants into local constants with good naming so it's easier to understand why we need these magic numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ash-google is this what you were looking for? cdf4d25

@ash2moon
Copy link
Contributor

ash2moon commented Feb 8, 2025

Did a second look over Android and LGTM. Let's wait for @ditman for web.

@jokerttu
Copy link
Contributor Author

jokerttu commented Feb 10, 2025

There is some crash issues on Android integration tests: Linux_android android_device_tests_shard_1 master
Haven't been able to re-produce the crash issue (with same sdk version as tests are runned). Not yet sure if these crashes are related to ground overlay implementation or not. These tests do not fail on each run, but quite often, so I would like to be sure if this is something that is not related to these changes.

@stuartmorgan-g
Copy link
Collaborator

There is some crash issues on Android integration tests: Linux_android android_device_tests_shard_1 master

It's flutter/flutter#159731. We're seeing flare-ups of this on other PRs that touch maps, so I don't think it's related. We've seen spikes in this crash in our CI before, potentially due to server-side changes in Google Maps.

@matijakevic
Copy link

I tested this implementation a bit on Android. Unfortunately, I ran into an issue which occurs when ground overlay images change quickly (<250ms interval). This results in a quick but noticeable black flicker.

The images are stored in-memory as Uint8List and loaded through BytesMapBitmap.

The GroundOverlay has the same unchanging groundOverlayId all the time, only the image is changing.

I am not sure what causes this, maybe the thread that updates the ground overlays doesn't manage to decode bitmaps from raw data quickly enough?

I attached a video demonstrating this on Xiaomi 12T. Maybe I could try creating minimal reproducible example if needed.

out.mp4

Copy link
Contributor

Choose a reason for hiding this comment

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

By default asserts are stripped in java. If you want to check this value then you will need to throw an exception or log or do some other form of error handling.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a link to what layer of the stack does not support this functionality? Also why is it safe to use a dummy image?

Copy link
Contributor Author

@jokerttu jokerttu Feb 14, 2025

Choose a reason for hiding this comment

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

This is used only by inpector api, for testing purposes. App facing widget stores groundoverlays on dart implementation, and there is no real reason to fetch the data back, other than testing.
Image is mandatory field on PlatformGroundOverlay (and it should be kept non-nullable), therefore image must be set for the object.
The image is description either contains set of bytes, or path to asset. This info is converted to format google maps uses (BitmapDescription), and the original data is not stored on native code.
So converting read and possibly rescaled asset bitmap back orginal instruction with asset url is not currently possible without storing the original PlatformImageDescriptor to memory; which is not optimal.
Therefore using dummy image here should be fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks this helps answer my question. Consider putting a shorter version of that in the code.

Maybe something like "Image is mandatory field on PlatformGroundOverlay (and it should be kept non-nullable), therefore image must be set for the object. The image is description either contains set of bytes, or path to asset. This info is converted to format google maps uses (BitmapDescription), and the original data is not stored on native code."

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting a helper method that takes a actual ground overlay object and expected values and handles the assertions for equals. It would make new tests easier to write/review.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment for why this value was chosen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to skip this for all platforms? if so should it be deleted instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this was committed by accident. Not related to this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a legacy of this file starting its life as a copy of the integration tests in google_maps_flutter. In the context of google_maps_flutter_android, Platform.isAndroid is just a confusing way of writing true, so this change was good.

if so should it be deleted instead?

I would prefer we keep it, because of the TODO above. We are starting to see features that do not work without an API key, so we will need to fix the CI limitation at some point. (I was working on it with infra folks a while ago, but that got derailed.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is true; but already reverted this change before I saw @stuartmorgan:n comment about this, as this was chore change, not related to ground overlay at all. I can commit this back, if it is ok to have unrelated changes in the PR as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's fine either way; if you've already reverted it don't worry about adding it back unless you feel like it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment explaining where these magic numbers come from?
I believe this is just bumping the bearing 10 degrees and making sure we dont go over 360 but that is after reading the whole pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jokerttu jokerttu requested a review from reidbaker February 19, 2025 08:39
@jokerttu
Copy link
Contributor Author

I'll address review comments made to main PR by @reidbaker later this week: #8432 (review)
This is still waiting review from @ditman as well.

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

I took a look at web since I'm not sure when @ditman will have time. Mostly it seems straightforward, but I have a couple of questions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The other types use a nullable gmaps object, and remove() also nulls it out. What's the reason for the different pattern here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this is-checking one type and then as-casting to a different type?

@jokerttu jokerttu force-pushed the feat/google_maps_flutter_ground_overlay_support_platform_impl branch from 29a8e41 to f482577 Compare March 17, 2025 07:32
@jokerttu jokerttu force-pushed the feat/google_maps_flutter_ground_overlay_support_platform_impl branch from 388c1c3 to e89bada Compare March 17, 2025 10:08
Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Web LGTM

@jokerttu
Copy link
Contributor Author

jokerttu commented Mar 18, 2025

@reidbaker are you going to check the changed made addressing these #8432 (review) (on this PR and also mirrored to original app facing PR)
or is the earlier approval still valid?

@reidbaker
Copy link
Contributor

Thanks for asking, @ash2moon's approval for android is good enough for me. Thank you for this change.

@jokerttu jokerttu added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
@auto-submit auto-submit bot merged commit 297d5a1 into flutter:main Mar 18, 2025
83 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 19, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Mar 19, 2025
flutter/packages@d450e1b...dd781d4

2025-03-19 [email protected] [camera_avfoundation] Tests
backfilling - part 4 (flutter/packages#8854)
2025-03-18 [email protected] [camera_avfoundation] Tests
backfilling - part 5 (flutter/packages#8873)
2025-03-18 [email protected] [video_player]: reduce video player
position update interval from 500ms to 100ms (flutter/packages#8346)
2025-03-18 [email protected] [google_maps_flutter] Support
for Ground Overlay (flutter/packages#8432)
2025-03-18 [email protected] [google_maps_flutter] Ground
overlay support - platform impls (flutter/packages#8563)

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] 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
androidseb pushed a commit to androidseb/packages that referenced this pull request Jun 8, 2025
…r#8563)

This PR contains platform implementations for the ground overlays support (flutter#8432).

Linked issue: flutter/flutter#26479
zhangyuang pushed a commit to zhangyuang/flutter-fork that referenced this pull request Jun 9, 2025
…r#165489)

flutter/packages@d450e1b...dd781d4

2025-03-19 [email protected] [camera_avfoundation] Tests
backfilling - part 4 (flutter/packages#8854)
2025-03-18 [email protected] [camera_avfoundation] Tests
backfilling - part 5 (flutter/packages#8873)
2025-03-18 [email protected] [video_player]: reduce video player
position update interval from 500ms to 100ms (flutter/packages#8346)
2025-03-18 [email protected] [google_maps_flutter] Support
for Ground Overlay (flutter/packages#8432)
2025-03-18 [email protected] [google_maps_flutter] Ground
overlay support - platform impls (flutter/packages#8563)

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] 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
…r#8563)

This PR contains platform implementations for the ground overlays support (flutter#8432).

Linked issue: flutter/flutter#26479
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
…r#165489)

flutter/packages@d450e1b...dd781d4

2025-03-19 [email protected] [camera_avfoundation] Tests
backfilling - part 4 (flutter/packages#8854)
2025-03-18 [email protected] [camera_avfoundation] Tests
backfilling - part 5 (flutter/packages#8873)
2025-03-18 [email protected] [video_player]: reduce video player
position update interval from 500ms to 100ms (flutter/packages#8346)
2025-03-18 [email protected] [google_maps_flutter] Support
for Ground Overlay (flutter/packages#8432)
2025-03-18 [email protected] [google_maps_flutter] Ground
overlay support - platform impls (flutter/packages#8563)

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] 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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-android platform-ios platform-web triage-web Should be looked at in web triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants