-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: animationAnimation APIsAnimation APIsa: leak trackingIssues and PRs related to memory leaks detected by leak_trackerIssues and PRs related to memory leaks detected by leak_trackera: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsfound in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
PR which marks this leak: #134839.
Steps to reproduce
- Add
leak-trackerinstrumentation to theAnimationController:
Constructor:
AnimationController({
double? value,
this.duration,
this.reverseDuration,
this.debugLabel,
this.lowerBound = 0.0,
this.upperBound = 1.0,
this.animationBehavior = AnimationBehavior.normal,
required TickerProvider vsync,
}) : assert(upperBound >= lowerBound),
_direction = _AnimationDirection.forward {
if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectCreated(
library: 'package:flutter/animation.dart',
className: '$AnimationController',
object: this,
);
}
_ticker = vsync.createTicker(_tick);
_internalSetValue(value ?? lowerBound);
}dispose() method:
@override
void dispose() {
assert(() {
if (_ticker == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('AnimationController.dispose() called more than once.'),
ErrorDescription('A given $runtimeType cannot be disposed more than once.\n'),
DiagnosticsProperty<AnimationController>(
'The following $runtimeType object was disposed multiple times',
this,
style: DiagnosticsTreeStyle.errorProperty,
),
]);
}
return true;
}());
if (kFlutterMemoryAllocationsEnabled) {
MemoryAllocations.instance.dispatchObjectDisposed(object: this);
}
_ticker!.dispose();
_ticker = null;
clearStatusListeners();
clearListeners();
super.dispose();
}- Test to reveal the leak:
testWidgetsWithLeakTracking('_MergeableMaterialState leak', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: MergeableMaterial(
children: <MergeableMaterialItem>[
MaterialSlice(
key: ValueKey<String>('A'),
child: SizedBox(
width: 100.0,
height: 100.0,
),
),
MaterialGap(
key: ValueKey<String>('-'),
),
MaterialSlice(
key: ValueKey<String>('B'),
child: SizedBox(
width: 100.0,
height: 100.0,
),
),
],
),
),
),
),
);
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: MergeableMaterial(
children: <MergeableMaterialItem>[
MaterialSlice(
key: ValueKey<String>('A'),
child: SizedBox(
width: 100.0,
height: 100.0,
),
),
],
),
),
),
),
);
}, leakTrackingTestConfig: LeakTrackingTestConfig.debugNotDisposed());Test output
Expected: leak free
Actual: <Instance of 'Leaks'>
Which: contains leaks:
# The text is generated by leak_tracker.
# For leak troubleshooting tips open:
# https://github.com/dart-lang/leak_tracker/blob/main/doc/TROUBLESHOOT.md
notDisposed:
total: 1
objects:
AnimationController:
test: _MergeableMaterialState leak
identityHashCode: 572261535
context:
start: >
#6_______flutterEventToLeakTracker_(package:leak_tracker_flutter_testing/src/test_widgets.dart:24:23)
#7______MemoryAllocations.dispatchObjectEvent_(package:flutter/src/foundation/memory_allocations.dart:238:23)
#8______MemoryAllocations.dispatchObjectCreated_(package:flutter/src/foundation/memory_allocations.dart:272:5)
#9______AnimationController._maybeDispatchObjectCreation_(package:flutter/src/animation/animation_controller.dart:289:34)
#10_____new_AnimationController_(package:flutter/src/animation/animation_controller.dart:249:5)
#11______MergeableMaterialState._initGap_(package:flutter/src/material/mergeable_material.dart:181:44)
#12______MergeableMaterialState.initState_(package:flutter/src/material/mergeable_material.dart:173:9)
#13_____StatefulElement._firstBuild_(package:flutter/src/widgets/framework.dart:5605:55)
#14_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5450:5)
#15_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#16_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#17_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#18_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#19_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#20_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#21_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#22_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#23_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#24_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#25_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#26_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#27_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#28_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#29_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#30_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#31_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#32_____ComponentElement.performRebuild_(package:flutter/src/widgets/framework.dart:5499:16)
#33_____StatefulElement.performRebuild_(package:flutter/src/widgets/framework.dart:5637:11)
#34_____Element.rebuild_(package:flutter/src/widgets/framework.dart:5190:7)
#35_____ComponentElement._firstBuild_(package:flutter/src/widgets/framework.dart:5456:5)
#36_____StatefulElement._firstBuild_(package:flutter/src/widgets/framework.dart:5628:11)
#37_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5450:5)
#38_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#39_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#40_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#41_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#42_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#43_____ComponentElement.performRebuild_(package:flutter/src/widgets/framework.dart:5499:16)
#44_____Element.rebuild_(package:flutter/src/widgets/framework.dart:5190:7)
#45_____ComponentElement._firstBuild_(package:flutter/src/widgets/framework.dart:5456:5)
#46_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5450:5)
#47_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#48_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#49_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#50_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#51_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#52_____ComponentElement.performRebuild_(package:flutter/src/widgets/framework.dart:5499:16)
#53_____Element.rebuild_(package:flutter/src/widgets/framework.dart:5190:7)
#54_____ComponentElement._firstBuild_(package:flutter/src/widgets/framework.dart:5456:5)
#55_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5450:5)
#56_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#57_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#58_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#59_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#60_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#61_____SingleChildRenderObjectElement.mount_(package:flutter/src/widgets/framework.dart:6649:14)
#62_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#63_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#64_____ComponentElement.performRebuild_(package:flutter/src/widgets/framework.dart:5499:16)
#65_____StatefulElement.performRebuild_(package:flutter/src/widgets/framework.dart:5637:11)
#66_____Element.rebuild_(package:flutter/src/widgets/framework.dart:5190:7)
#67_____ComponentElement._firstBuild_(package:flutter/src/widgets/framework.dart:5456:5)
#68_____StatefulElement._firstBuild_(package:flutter/src/widgets/framework.dart:5628:11)
#69_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5450:5)
#70_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#71_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#72_____ComponentElement.performRebuild_(package:flutter/src/widgets/framework.dart:5499:16)
#73_____Element.rebuild_(package:flutter/src/widgets/framework.dart:5190:7)
#74_____ComponentElement._firstBuild_(package:flutter/src/widgets/framework.dart:5456:5)
#75_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5450:5)
#76_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#77_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
#78_____ComponentElement.performRebuild_(package:flutter/src/widgets/framework.dart:5499:16)
#79_____StatefulElement.performRebuild_(package:flutter/src/widgets/framework.dart:5637:11)
#80_____Element.rebuild_(package:flutter/src/widgets/framework.dart:5190:7)
#81_____ComponentElement._firstBuild_(package:flutter/src/widgets/framework.dart:5456:5)
#82_____StatefulElement._firstBuild_(package:flutter/src/widgets/framework.dart:5628:11)
#83_____ComponentElement.mount_(package:flutter/src/widgets/framework.dart:5450:5)
#84_____Element.inflateWidget_(package:flutter/src/widgets/framework.dart:4329:16)
#85_____Element.updateChild_(package:flutter/src/widgets/framework.dart:3840:18)
...Flutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.14.0-14.0.pre.312, on macOS 13.0.1 22A400 darwin-arm64, locale en-GB)
• Flutter version 3.14.0-14.0.pre.312 on channel master at /Users/ksokolovskyi/dev/flutter_master
• Upstream repository [email protected]:ksokolovskyi/flutter.git
• FLUTTER_GIT_URL = [email protected]:ksokolovskyi/flutter.git
• Framework revision 72b69f9449 (4 hours ago), 2023-09-15 08:55:50 -0700
• Engine revision 45bc4307cd
• Dart version 3.2.0 (build 3.2.0-162.0.dev)
• DevTools version 2.28.0-dev.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/ksokolovskyi/Library/Android/sdk
• Platform android-34, build-tools 33.0.1
• ANDROID_HOME = /Users/ksokolovskyi/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Community Edition (version 2023.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.82.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.72.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.0.1 22A400 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.187
[✓] Network resources
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: animationAnimation APIsAnimation APIsa: leak trackingIssues and PRs related to memory leaks detected by leak_trackerIssues and PRs related to memory leaks detected by leak_trackera: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsfound in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team