-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[Android] Remove overlay when platform views are removed from screen. #162908
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
Conversation
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
FYI @johnmccutchan |
| // This should appear as the yellow line over a blue box. The | ||
| // green box should not be visible unless the platform view has not loaded yet or | ||
| // has been removed from the scene. | ||
| final class MainApp extends StatefulWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a note, it might make sense to add this style of overlay test for all the PV backends (instead of HC++ specific), and then instead revert the box I added in #162903 (I like your implementation more).
It doesn't have to be in this PR, but do it as an immediate follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| // Note: this doesn't reset the app so if additional test cases are added | ||
| // make sure to press the button again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just hit the button as a result of finishing the test, right?
addTearDown(() async {
// Reset the state regardless of the test passing or not.
await flutterDriver.tap(find.byValueKey('AddOverlay'));
});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| // Note: this doesn't reset the app so if additional test cases are added | ||
| // make sure to press the button again. | ||
| test('should remove overlay when platform view is removed', () async { | ||
| await flutterDriver.tap(find.byValueKey('RemoveOverlay')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is pressing AddOverlay to begin with? Or is that the default state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add overlay is the default state.
matanlurey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One requested change (or fast-follow up, your choice) and one clarification/improvement to a test.
matanlurey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for addressing and improving the shared tests!
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
I think we've just had a bug in HC mode sitting there. I think this should fix it lol |
Roll Flutter from 892f9c1 to e8f34a9 (71 revisions) flutter/flutter@892f9c1...e8f34a9 2025-02-12 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Skia from f31c733c86c4 to 25937c31f153 (2 revisions) (#163127)" (flutter/flutter#163133) 2025-02-12 [email protected] Roll Skia from f31c733c86c4 to 25937c31f153 (2 revisions) (flutter/flutter#163127) 2025-02-12 [email protected] Update .ci.yaml to support Fuchsia cherrypick branches (flutter/flutter#163000) 2025-02-12 [email protected] Roll Skia from 6f17f2ebb2e5 to f31c733c86c4 (1 revision) (flutter/flutter#163112) 2025-02-12 [email protected] Roll Skia from a9dbb2479c26 to 6f17f2ebb2e5 (2 revisions) (flutter/flutter#163109) 2025-02-12 [email protected] [devicelab] dont strip symbols in platform views layout test. (flutter/flutter#163101) 2025-02-12 [email protected] [Impeller] mirror tile mode requires highp for Adreno. (flutter/flutter#163066) 2025-02-12 [email protected] Roll Skia from 5b56d9a91633 to a9dbb2479c26 (6 revisions) (flutter/flutter#163100) 2025-02-12 [email protected] Roll Dart SDK from d9d7f103b6b7 to fcef25f18e4d (3 revisions) (flutter/flutter#163098) 2025-02-12 [email protected] Generate a correct `.flutter-plugin-dependencies` file for iOS/macOS projects (flutter/flutter#162834) 2025-02-12 [email protected] Remove unsound artifacts, remove `*Sound` qualifier. (flutter/flutter#163015) 2025-02-12 [email protected] [Impeller] libImpeller: Add support for Metal and Vulkan rendering. (flutter/flutter#161547) 2025-02-11 [email protected] Marks Mac_benchmark basic_material_app_macos__compile to be flaky (flutter/flutter#162365) 2025-02-11 [email protected] Roll pub packages (flutter/flutter#163083) 2025-02-11 [email protected] Adds hasSelectedState parameter to matchesSemantics for migration (flutter/flutter#163014) 2025-02-11 [email protected] fix: Dispose codec after completing frame creation (flutter/flutter#159945) 2025-02-11 [email protected] [ios][secure_paste]show menu item based on info sent from framework (flutter/flutter#161103) 2025-02-11 [email protected] Update conductor to support monorepos (flutter/flutter#161704) 2025-02-11 [email protected] [Android] fix hcpp tapping, again, and add test. (flutter/flutter#163035) 2025-02-11 [email protected] Add new builder for experiment with dynamic modules. (flutter/flutter#162855) 2025-02-11 [email protected] Roll vulkan-deps to 9edf248c597b (flutter/flutter#162549) 2025-02-11 [email protected] Adds dialog and alertdialog role (flutter/flutter#162692) 2025-02-11 [email protected] Roll Dart SDK from 99789828cc95 to d9d7f103b6b7 (12 revisions) (flutter/flutter#163060) 2025-02-11 [email protected] [ Widget Preview ] Cleanup PreviewDetector code (flutter/flutter#163050) 2025-02-11 [email protected] Fix `SkiaException` -> `TestFailure`, add tests. (flutter/flutter#163054) 2025-02-11 [email protected] [Android] fix hcpp overlay layer intersection. (flutter/flutter#163024) 2025-02-11 [email protected] [ Widget Preview ] Update generated scaffold project to include early preview rendering (flutter/flutter#162847) 2025-02-11 [email protected] [Embedder] Implement merged platform and UI thread (flutter/flutter#162944) 2025-02-11 [email protected] [Android] Remove overlay when platform views are removed from screen. (flutter/flutter#162908) 2025-02-11 [email protected] Roll Dart to 3.8.0-76.0.dev (flutter/flutter#162913) 2025-02-11 [email protected] [Android] add HCPP platform views benchmark and integration test. (flutter/flutter#163018) 2025-02-11 [email protected] Roll Skia from 8c377e8bedd2 to 5b56d9a91633 (9 revisions) (flutter/flutter#163021) 2025-02-11 [email protected] Try golden-testing on a Mokey (`bringup: true`), retry on an emulator (flutter/flutter#163029) 2025-02-11 [email protected] Fix Linux keyboard support for AltGr (flutter/flutter#162495) 2025-02-11 [email protected] Update gen_keycodes output to new engine location. (flutter/flutter#162479) 2025-02-10 [email protected] [Android] add runtime flag to determine if HCPP is supported. (flutter/flutter#163004) 2025-02-10 [email protected] [iOS][Engine] Fix view removal process for AutofillContextAction.cancel (flutter/flutter#160653) 2025-02-10 [email protected] Re-land #162644: Remove `--verbose` from devicelab task executions. (flutter/flutter#163017) 2025-02-10 [email protected] Include device lab version for how to run test (flutter/flutter#163010) 2025-02-10 [email protected] Change the default optimization level to `-O2` for wasm in release mode. (flutter/flutter#162917) 2025-02-10 [email protected] [web] robustify safaridriver launch sequence (flutter/flutter#162919) 2025-02-10 [email protected] Return more eagerly when toggling service extensions (flutter/flutter#162774) 2025-02-10 [email protected] Fix doc reference typos (flutter/flutter#162893) 2025-02-10 [email protected] Roll Skia from 180ed4fc263d to 8c377e8bedd2 (4 revisions) (flutter/flutter#162998) 2025-02-10 [email protected] FYI matanlurey (does not require review, but probably should) on dev/test infra. (flutter/flutter#162642) 2025-02-10 [email protected] [Impeller] rrect_blur: scale max radius clamp by transform (flutter/flutter#161238) ...
Roll Flutter from 892f9c1 to e8f34a9 (71 revisions) flutter/flutter@892f9c1...e8f34a9 2025-02-12 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Skia from f31c733c86c4 to 25937c31f153 (2 revisions) (#163127)" (flutter/flutter#163133) 2025-02-12 [email protected] Roll Skia from f31c733c86c4 to 25937c31f153 (2 revisions) (flutter/flutter#163127) 2025-02-12 [email protected] Update .ci.yaml to support Fuchsia cherrypick branches (flutter/flutter#163000) 2025-02-12 [email protected] Roll Skia from 6f17f2ebb2e5 to f31c733c86c4 (1 revision) (flutter/flutter#163112) 2025-02-12 [email protected] Roll Skia from a9dbb2479c26 to 6f17f2ebb2e5 (2 revisions) (flutter/flutter#163109) 2025-02-12 [email protected] [devicelab] dont strip symbols in platform views layout test. (flutter/flutter#163101) 2025-02-12 [email protected] [Impeller] mirror tile mode requires highp for Adreno. (flutter/flutter#163066) 2025-02-12 [email protected] Roll Skia from 5b56d9a91633 to a9dbb2479c26 (6 revisions) (flutter/flutter#163100) 2025-02-12 [email protected] Roll Dart SDK from d9d7f103b6b7 to fcef25f18e4d (3 revisions) (flutter/flutter#163098) 2025-02-12 [email protected] Generate a correct `.flutter-plugin-dependencies` file for iOS/macOS projects (flutter/flutter#162834) 2025-02-12 [email protected] Remove unsound artifacts, remove `*Sound` qualifier. (flutter/flutter#163015) 2025-02-12 [email protected] [Impeller] libImpeller: Add support for Metal and Vulkan rendering. (flutter/flutter#161547) 2025-02-11 [email protected] Marks Mac_benchmark basic_material_app_macos__compile to be flaky (flutter/flutter#162365) 2025-02-11 [email protected] Roll pub packages (flutter/flutter#163083) 2025-02-11 [email protected] Adds hasSelectedState parameter to matchesSemantics for migration (flutter/flutter#163014) 2025-02-11 [email protected] fix: Dispose codec after completing frame creation (flutter/flutter#159945) 2025-02-11 [email protected] [ios][secure_paste]show menu item based on info sent from framework (flutter/flutter#161103) 2025-02-11 [email protected] Update conductor to support monorepos (flutter/flutter#161704) 2025-02-11 [email protected] [Android] fix hcpp tapping, again, and add test. (flutter/flutter#163035) 2025-02-11 [email protected] Add new builder for experiment with dynamic modules. (flutter/flutter#162855) 2025-02-11 [email protected] Roll vulkan-deps to 9edf248c597b (flutter/flutter#162549) 2025-02-11 [email protected] Adds dialog and alertdialog role (flutter/flutter#162692) 2025-02-11 [email protected] Roll Dart SDK from 99789828cc95 to d9d7f103b6b7 (12 revisions) (flutter/flutter#163060) 2025-02-11 [email protected] [ Widget Preview ] Cleanup PreviewDetector code (flutter/flutter#163050) 2025-02-11 [email protected] Fix `SkiaException` -> `TestFailure`, add tests. (flutter/flutter#163054) 2025-02-11 [email protected] [Android] fix hcpp overlay layer intersection. (flutter/flutter#163024) 2025-02-11 [email protected] [ Widget Preview ] Update generated scaffold project to include early preview rendering (flutter/flutter#162847) 2025-02-11 [email protected] [Embedder] Implement merged platform and UI thread (flutter/flutter#162944) 2025-02-11 [email protected] [Android] Remove overlay when platform views are removed from screen. (flutter/flutter#162908) 2025-02-11 [email protected] Roll Dart to 3.8.0-76.0.dev (flutter/flutter#162913) 2025-02-11 [email protected] [Android] add HCPP platform views benchmark and integration test. (flutter/flutter#163018) 2025-02-11 [email protected] Roll Skia from 8c377e8bedd2 to 5b56d9a91633 (9 revisions) (flutter/flutter#163021) 2025-02-11 [email protected] Try golden-testing on a Mokey (`bringup: true`), retry on an emulator (flutter/flutter#163029) 2025-02-11 [email protected] Fix Linux keyboard support for AltGr (flutter/flutter#162495) 2025-02-11 [email protected] Update gen_keycodes output to new engine location. (flutter/flutter#162479) 2025-02-10 [email protected] [Android] add runtime flag to determine if HCPP is supported. (flutter/flutter#163004) 2025-02-10 [email protected] [iOS][Engine] Fix view removal process for AutofillContextAction.cancel (flutter/flutter#160653) 2025-02-10 [email protected] Re-land #162644: Remove `--verbose` from devicelab task executions. (flutter/flutter#163017) 2025-02-10 [email protected] Include device lab version for how to run test (flutter/flutter#163010) 2025-02-10 [email protected] Change the default optimization level to `-O2` for wasm in release mode. (flutter/flutter#162917) 2025-02-10 [email protected] [web] robustify safaridriver launch sequence (flutter/flutter#162919) 2025-02-10 [email protected] Return more eagerly when toggling service extensions (flutter/flutter#162774) 2025-02-10 [email protected] Fix doc reference typos (flutter/flutter#162893) 2025-02-10 [email protected] Roll Skia from 180ed4fc263d to 8c377e8bedd2 (4 revisions) (flutter/flutter#162998) 2025-02-10 [email protected] FYI matanlurey (does not require review, but probably should) on dev/test infra. (flutter/flutter#162642) 2025-02-10 [email protected] [Impeller] rrect_blur: scale max radius clamp by transform (flutter/flutter#161238) ...
Roll Flutter from 892f9c1 to e8f34a9 (71 revisions) flutter/flutter@892f9c1...e8f34a9 2025-02-12 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Skia from f31c733c86c4 to 25937c31f153 (2 revisions) (#163127)" (flutter/flutter#163133) 2025-02-12 [email protected] Roll Skia from f31c733c86c4 to 25937c31f153 (2 revisions) (flutter/flutter#163127) 2025-02-12 [email protected] Update .ci.yaml to support Fuchsia cherrypick branches (flutter/flutter#163000) 2025-02-12 [email protected] Roll Skia from 6f17f2ebb2e5 to f31c733c86c4 (1 revision) (flutter/flutter#163112) 2025-02-12 [email protected] Roll Skia from a9dbb2479c26 to 6f17f2ebb2e5 (2 revisions) (flutter/flutter#163109) 2025-02-12 [email protected] [devicelab] dont strip symbols in platform views layout test. (flutter/flutter#163101) 2025-02-12 [email protected] [Impeller] mirror tile mode requires highp for Adreno. (flutter/flutter#163066) 2025-02-12 [email protected] Roll Skia from 5b56d9a91633 to a9dbb2479c26 (6 revisions) (flutter/flutter#163100) 2025-02-12 [email protected] Roll Dart SDK from d9d7f103b6b7 to fcef25f18e4d (3 revisions) (flutter/flutter#163098) 2025-02-12 [email protected] Generate a correct `.flutter-plugin-dependencies` file for iOS/macOS projects (flutter/flutter#162834) 2025-02-12 [email protected] Remove unsound artifacts, remove `*Sound` qualifier. (flutter/flutter#163015) 2025-02-12 [email protected] [Impeller] libImpeller: Add support for Metal and Vulkan rendering. (flutter/flutter#161547) 2025-02-11 [email protected] Marks Mac_benchmark basic_material_app_macos__compile to be flaky (flutter/flutter#162365) 2025-02-11 [email protected] Roll pub packages (flutter/flutter#163083) 2025-02-11 [email protected] Adds hasSelectedState parameter to matchesSemantics for migration (flutter/flutter#163014) 2025-02-11 [email protected] fix: Dispose codec after completing frame creation (flutter/flutter#159945) 2025-02-11 [email protected] [ios][secure_paste]show menu item based on info sent from framework (flutter/flutter#161103) 2025-02-11 [email protected] Update conductor to support monorepos (flutter/flutter#161704) 2025-02-11 [email protected] [Android] fix hcpp tapping, again, and add test. (flutter/flutter#163035) 2025-02-11 [email protected] Add new builder for experiment with dynamic modules. (flutter/flutter#162855) 2025-02-11 [email protected] Roll vulkan-deps to 9edf248c597b (flutter/flutter#162549) 2025-02-11 [email protected] Adds dialog and alertdialog role (flutter/flutter#162692) 2025-02-11 [email protected] Roll Dart SDK from 99789828cc95 to d9d7f103b6b7 (12 revisions) (flutter/flutter#163060) 2025-02-11 [email protected] [ Widget Preview ] Cleanup PreviewDetector code (flutter/flutter#163050) 2025-02-11 [email protected] Fix `SkiaException` -> `TestFailure`, add tests. (flutter/flutter#163054) 2025-02-11 [email protected] [Android] fix hcpp overlay layer intersection. (flutter/flutter#163024) 2025-02-11 [email protected] [ Widget Preview ] Update generated scaffold project to include early preview rendering (flutter/flutter#162847) 2025-02-11 [email protected] [Embedder] Implement merged platform and UI thread (flutter/flutter#162944) 2025-02-11 [email protected] [Android] Remove overlay when platform views are removed from screen. (flutter/flutter#162908) 2025-02-11 [email protected] Roll Dart to 3.8.0-76.0.dev (flutter/flutter#162913) 2025-02-11 [email protected] [Android] add HCPP platform views benchmark and integration test. (flutter/flutter#163018) 2025-02-11 [email protected] Roll Skia from 8c377e8bedd2 to 5b56d9a91633 (9 revisions) (flutter/flutter#163021) 2025-02-11 [email protected] Try golden-testing on a Mokey (`bringup: true`), retry on an emulator (flutter/flutter#163029) 2025-02-11 [email protected] Fix Linux keyboard support for AltGr (flutter/flutter#162495) 2025-02-11 [email protected] Update gen_keycodes output to new engine location. (flutter/flutter#162479) 2025-02-10 [email protected] [Android] add runtime flag to determine if HCPP is supported. (flutter/flutter#163004) 2025-02-10 [email protected] [iOS][Engine] Fix view removal process for AutofillContextAction.cancel (flutter/flutter#160653) 2025-02-10 [email protected] Re-land #162644: Remove `--verbose` from devicelab task executions. (flutter/flutter#163017) 2025-02-10 [email protected] Include device lab version for how to run test (flutter/flutter#163010) 2025-02-10 [email protected] Change the default optimization level to `-O2` for wasm in release mode. (flutter/flutter#162917) 2025-02-10 [email protected] [web] robustify safaridriver launch sequence (flutter/flutter#162919) 2025-02-10 [email protected] Return more eagerly when toggling service extensions (flutter/flutter#162774) 2025-02-10 [email protected] Fix doc reference typos (flutter/flutter#162893) 2025-02-10 [email protected] Roll Skia from 180ed4fc263d to 8c377e8bedd2 (4 revisions) (flutter/flutter#162998) 2025-02-10 [email protected] FYI matanlurey (does not require review, but probably should) on dev/test infra. (flutter/flutter#162642) 2025-02-10 [email protected] [Impeller] rrect_blur: scale max radius clamp by transform (flutter/flutter#161238) ...
Fixes #175882. This ended up being a very similar bug to #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 #173881 (comment) 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 #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 <[email protected]>
…#176742) Fixes flutter#175882. This ended up being a very similar bug to flutter#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 flutter#173881 (comment) 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 flutter#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 <[email protected]>
When there are no more platform views, make sure the overlay layer is hidden. When a platform view is added again, show the overlay. The show/hide allows us to avoid continually recreating and destroying the overlay surface + swapchain when a platform view slides in and out of frame.
To further reduce memory usage, we could do a delayed de-allocation of the overlay layer (say after 50 frames of no platform view, destroy it). But I'm leaving this to a follow up.