Unverified Commit 39befd81 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Clean leaks. (#142818)

parent a2c7ed95
...@@ -889,9 +889,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ...@@ -889,9 +889,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
static const Duration _minimumInteractionTime = Duration(milliseconds: 500); static const Duration _minimumInteractionTime = Duration(milliseconds: 500);
final _RangeSliderState _state; final _RangeSliderState _state;
late Animation<double> _overlayAnimation; late CurvedAnimation _overlayAnimation;
late Animation<double> _valueIndicatorAnimation; late CurvedAnimation _valueIndicatorAnimation;
late Animation<double> _enableAnimation; late CurvedAnimation _enableAnimation;
final TextPainter _startLabelPainter = TextPainter(); final TextPainter _startLabelPainter = TextPainter();
final TextPainter _endLabelPainter = TextPainter(); final TextPainter _endLabelPainter = TextPainter();
late HorizontalDragGestureRecognizer _drag; late HorizontalDragGestureRecognizer _drag;
...@@ -1185,6 +1185,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ...@@ -1185,6 +1185,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
_tap.dispose(); _tap.dispose();
_startLabelPainter.dispose(); _startLabelPainter.dispose();
_endLabelPainter.dispose(); _endLabelPainter.dispose();
_enableAnimation.dispose();
_valueIndicatorAnimation.dispose();
_overlayAnimation.dispose();
super.dispose(); super.dispose();
} }
......
...@@ -1322,11 +1322,11 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr ...@@ -1322,11 +1322,11 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
// Controls the previous widget.child as it exits. // Controls the previous widget.child as it exits.
late AnimationController _previousController; late AnimationController _previousController;
late Animation<double> _previousScaleAnimation; late Animation<double> _previousScaleAnimation;
late Animation<double> _previousRotationAnimation; late TrainHoppingAnimation _previousRotationAnimation;
// The animations to run, considering the widget's fabMoveAnimation and the current/previous entrance/exit animations. // The animations to run, considering the widget's fabMoveAnimation and the current/previous entrance/exit animations.
late Animation<double> _currentScaleAnimation; late Animation<double> _currentScaleAnimation;
late Animation<double> _extendedCurrentScaleAnimation; late Animation<double> _extendedCurrentScaleAnimation;
late Animation<double> _currentRotationAnimation; late TrainHoppingAnimation _currentRotationAnimation;
Widget? _previousChild; Widget? _previousChild;
@override @override
...@@ -1353,6 +1353,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr ...@@ -1353,6 +1353,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
@override @override
void dispose() { void dispose() {
_previousController.dispose(); _previousController.dispose();
_disposeAnimations();
super.dispose(); super.dispose();
} }
...@@ -1360,6 +1361,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr ...@@ -1360,6 +1361,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
void didUpdateWidget(_FloatingActionButtonTransition oldWidget) { void didUpdateWidget(_FloatingActionButtonTransition oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.fabMotionAnimator != widget.fabMotionAnimator || oldWidget.fabMoveAnimation != widget.fabMoveAnimation) { if (oldWidget.fabMotionAnimator != widget.fabMotionAnimator || oldWidget.fabMoveAnimation != widget.fabMoveAnimation) {
_disposeAnimations();
// Get the right scale and rotation animations to use for this widget. // Get the right scale and rotation animations to use for this widget.
_updateAnimations(); _updateAnimations();
} }
...@@ -1395,6 +1397,11 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr ...@@ -1395,6 +1397,11 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
end: 1.0, end: 1.0,
).chain(CurveTween(curve: Curves.easeIn)); ).chain(CurveTween(curve: Curves.easeIn));
void _disposeAnimations() {
_previousRotationAnimation.dispose();
_currentRotationAnimation.dispose();
}
void _updateAnimations() { void _updateAnimations() {
// Get the animations for exit and entrance. // Get the animations for exit and entrance.
final CurvedAnimation previousExitScaleAnimation = CurvedAnimation( final CurvedAnimation previousExitScaleAnimation = CurvedAnimation(
......
...@@ -812,15 +812,16 @@ class _StretchController extends ChangeNotifier { ...@@ -812,15 +812,16 @@ class _StretchController extends ChangeNotifier {
} }
_stretchController = AnimationController(vsync: vsync) _stretchController = AnimationController(vsync: vsync)
..addStatusListener(_changePhase); ..addStatusListener(_changePhase);
final Animation<double> decelerator = CurvedAnimation( _decelerator = CurvedAnimation(
parent: _stretchController, parent: _stretchController,
curve: Curves.decelerate, curve: Curves.decelerate,
)..addListener(notifyListeners); )..addListener(notifyListeners);
_stretchSize = decelerator.drive(_stretchSizeTween); _stretchSize = _decelerator.drive(_stretchSizeTween);
} }
late final AnimationController _stretchController; late final AnimationController _stretchController;
late final Animation<double> _stretchSize; late final Animation<double> _stretchSize;
late final CurvedAnimation _decelerator;
final Tween<double> _stretchSizeTween = Tween<double>(begin: 0.0, end: 0.0); final Tween<double> _stretchSizeTween = Tween<double>(begin: 0.0, end: 0.0);
_StretchState _state = _StretchState.idle; _StretchState _state = _StretchState.idle;
...@@ -923,6 +924,7 @@ class _StretchController extends ChangeNotifier { ...@@ -923,6 +924,7 @@ class _StretchController extends ChangeNotifier {
@override @override
void dispose() { void dispose() {
_stretchController.dispose(); _stretchController.dispose();
_decelerator.dispose();
super.dispose(); super.dispose();
} }
......
...@@ -9,7 +9,6 @@ library; ...@@ -9,7 +9,6 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
/* /*
...@@ -78,10 +77,7 @@ void main() { ...@@ -78,10 +77,7 @@ void main() {
// Currently skipped due to daily flake: https://github.com/flutter/flutter/issues/87588 // Currently skipped due to daily flake: https://github.com/flutter/flutter/issues/87588
}, skip: true); // Typically skip: isBrowser https://github.com/flutter/flutter/issues/42767 }, skip: true); // Typically skip: isBrowser https://github.com/flutter/flutter/issues/42767
testWidgets('Should show event indicator for pointer events with setSurfaceSize', testWidgets('Should show event indicator for pointer events with setSurfaceSize', (WidgetTester tester) async {
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true); final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true);
addTearDown(animationSheet.dispose); addTearDown(animationSheet.dispose);
final List<Offset> taps = <Offset>[]; final List<Offset> taps = <Offset>[];
......
...@@ -10,7 +10,6 @@ import 'package:flutter/cupertino.dart'; ...@@ -10,7 +10,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
late FakeBuilder mockHelper; late FakeBuilder mockHelper;
...@@ -35,10 +34,7 @@ void main() { ...@@ -35,10 +34,7 @@ void main() {
} }
void uiTestGroup() { void uiTestGroup() {
testWidgets("doesn't invoke anything without user interaction", testWidgets("doesn't invoke anything without user interaction", (WidgetTester tester) async {
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
......
...@@ -18,7 +18,7 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; ...@@ -18,7 +18,7 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('ImageDecoration.lerp', testWidgets('ImageDecoration.lerp',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean] // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(), experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async { (WidgetTester tester) async {
final MemoryImage green = MemoryImage(Uint8List.fromList(<int>[ final MemoryImage green = MemoryImage(Uint8List.fromList(<int>[
...@@ -195,7 +195,7 @@ void main() { ...@@ -195,7 +195,7 @@ void main() {
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609 }, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
testWidgets('ImageDecoration.lerp', testWidgets('ImageDecoration.lerp',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean] // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(), experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async { (WidgetTester tester) async {
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[ final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
...@@ -416,7 +416,7 @@ void main() { ...@@ -416,7 +416,7 @@ void main() {
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609 }, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
testWidgets('ImageDecoration.lerp with colored background', testWidgets('ImageDecoration.lerp with colored background',
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean] // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(), experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async { (WidgetTester tester) async {
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[ final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
......
...@@ -78,7 +78,7 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter { ...@@ -78,7 +78,7 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter {
} }
void main() { void main() {
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean] // TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
LeakTesting.settings = LeakTesting.settings.withIgnoredAll(); LeakTesting.settings = LeakTesting.settings.withIgnoredAll();
late Image image20x10; late Image image20x10;
......
...@@ -5,15 +5,11 @@ ...@@ -5,15 +5,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgets('SemanticsNodes overlapping in z', testWidgets('SemanticsNodes overlapping in z', (WidgetTester tester) async {
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
// Cards are semantic boundaries that always own their own SemanticNode, // Cards are semantic boundaries that always own their own SemanticNode,
// PhysicalModels merge their semantics information into parent. // PhysicalModels merge their semantics information into parent.
// //
......
...@@ -15,16 +15,12 @@ import 'package:flutter/gestures.dart'; ...@@ -15,16 +15,12 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart'; import 'semantics_tester.dart';
void main() { void main() {
group('RawImage', () { group('RawImage', () {
testWidgets('properties', testWidgets('properties', (WidgetTester tester) async {
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
(WidgetTester tester) async {
final ui.Image image1 = (await tester.runAsync<ui.Image>(() => createTestImage()))!; final ui.Image image1 = (await tester.runAsync<ui.Image>(() => createTestImage()))!;
await tester.pumpWidget( await tester.pumpWidget(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment