_RenderSnapshotWidget should dispose created OffsetLayer. (#136267)

This commit is contained in:
Kostia Sokolovskyi
2023-10-11 17:45:39 +02:00
committed by GitHub
parent 54d584740b
commit cc41e25f21
2 changed files with 4 additions and 13 deletions

View File

@@ -306,6 +306,7 @@ class _RenderSnapshotWidget extends RenderProxyBox {
// ignore: invalid_use_of_protected_member
context.stopRecordingIfNeeded();
if (mode != SnapshotMode.forced && !offsetLayer.supportsRasterization()) {
offsetLayer.dispose();
if (mode == SnapshotMode.normal) {
throw FlutterError('SnapshotWidget used with a child that contains a PlatformView.');
}

View File

@@ -217,7 +217,7 @@ void main() {
}, skip: kIsWeb); // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/106689
testWidgets('RenderSnapshotWidget throws assertion if platform view is encountered', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RenderSnapshotWidget throws assertion if platform view is encountered', (WidgetTester tester) async {
final SnapshotController controller = SnapshotController(allowSnapshotting: true);
addTearDown(controller.dispose);
@@ -286,12 +286,7 @@ void main() {
expect(tester.takeException(), isNull);
expect(tester.layers.last, isA<PlatformViewLayer>());
},
skip: kIsWeb, // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/106689
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/135141
allowAllNotDisposed: true,
));
skip: kIsWeb); // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/106689
testWidgetsWithLeakTracking('SnapshotWidget should have same result when enabled', (WidgetTester tester) async {
addTearDown(tester.view.reset);
@@ -330,12 +325,7 @@ void main() {
await expectLater(find.byKey(repaintBoundaryKey), matchesReferenceImage(imageWhenDisabled));
},
skip: kIsWeb, // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/106689
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/135137
notDisposedAllowList: <String, int> {'Image': 1},
));
skip: kIsWeb); // TODO(jonahwilliams): https://github.com/flutter/flutter/issues/106689
}
class TestPlatformView extends SingleChildRenderObjectWidget {