Gray Mackall 1969110cb6
[HCPP] Properly remove hcpp views that are no longer visible (#176742)
Fixes https://github.com/flutter/flutter/issues/175882.

This ended up being a very similar bug to
https://github.com/flutter/flutter/pull/173881, and in my understanding
comes from the same incorrect assumption. In old PV land these views
would stop displaying if we stopped sending updates to them. But in HCPP
the underlying implementation ends up using an Android SurfaceFlinger
which continues displaying what it was last told to. So again we have a
bug here were we aren't taking the new responsibility of clearing that
we need to. See
https://github.com/flutter/flutter/pull/173881#discussion_r2283287104

Other solutions would be to just always call hide on the set of (keys of
view_params which are not in composition order) on every frame (which
would avoid this mirroring of state), or to modify the jni here to pass
over one big bundle with all the information required to do all the
existing calls as well as determine which views need to be hidden. But
we are already doing this same mirroring of visibility state for the
overlay layer (see Hide/ShowOverlayLayerIfNeeded()), so I think it is
reasonable to take the same approach here.

This is sort of a follow up to
https://github.com/flutter/flutter/pull/162908 as well, this PR properly
removes the view when it is the last platform view, but does not fix the
case that this PR attempts to more generally fix where we go from 2->1
(or n->n-1 > 0) pvs.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Gray Mackall <mackall@google.com>
2025-10-10 07:00:11 +00:00
..

Everything under this file path will have hcpp enabled, see the configuration here: 337a007f5c/dev/bots/suite_runners/run_android_engine_tests.dart (L34)