[Android] Remove overlay when platform views are removed from screen. (#162908)
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.
This commit is contained in:
@@ -41,6 +41,8 @@ void main() async {
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
await flutterDriver.tap(find.byValueKey('AddOverlay'));
|
||||
|
||||
await nativeDriver.close();
|
||||
await flutterDriver.close();
|
||||
});
|
||||
@@ -72,4 +74,16 @@ void main() async {
|
||||
matchesGoldenFile('$goldenPrefix.platform_view_portait_rotated_back.png'),
|
||||
);
|
||||
}, timeout: Timeout.none);
|
||||
|
||||
// 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'));
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile('$goldenPrefix.removed_overlay.png'),
|
||||
);
|
||||
}, timeout: Timeout.none);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user