-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
a: leak trackingIssues and PRs related to memory leaks detected by leak_trackerIssues and PRs related to memory leaks detected by leak_tracker
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
_MatchesReferenceImage matcher does not dispose created ui.Image instance.
Test to reveal the leak:
import 'dart:ui' as ui;
...
testWidgetsWithLeakTracking('_MatchesReferenceImage leak', (WidgetTester tester) async {
addTearDown(tester.view.reset);
tester.view
..physicalSize = const Size(10, 10)
..devicePixelRatio = 1;
const ValueKey<String> repaintBoundaryKey = ValueKey<String>('boundary');
await tester.pumpWidget(
const RepaintBoundary(
key: repaintBoundaryKey,
child: ColoredBox(
color: Colors.blue,
),
),
);
final ui.Image referenceImage = (tester.renderObject(find.byKey(repaintBoundaryKey)) as RenderRepaintBoundary).toImageSync();
addTearDown(referenceImage.dispose);
await expectLater(find.byKey(repaintBoundaryKey), matchesReferenceImage(referenceImage));
}, leakTrackingTestConfig: LeakTrackingTestConfig.debugNotDisposed());Test output
_MatchesReferenceImage leak
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:
Image:
test: _MatchesReferenceImage leak
identityHashCode: 23372313
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:241:23)
#8______MemoryAllocations._imageOnCreate_(package:flutter/src/foundation/memory_allocations.dart:315:5)
#9______new_Image.__(dart:ui/painting.dart:1717:15)
#10______NativeScene.toImage.<anonymous_closure>.<anonymous_closure>_(dart:ui/compositing.dart:71:26)
#11_____FfiTrampoline___toImage$Method$FfiNative$Ptr_(dart:ffi)
#12______NativeScene._toImage_(dart:ui/compositing.dart:78:20)
#13______NativeScene.toImage.<anonymous_closure>_(dart:ui/compositing.dart:67:54)
#14______futurize_(dart:ui/painting.dart:6933:35)
#15______NativeScene.toImage_(dart:ui/compositing.dart:67:12)
#16_____OffsetLayer.toImage_(package:flutter/src/rendering/layer.dart:1554:26)
#17_____captureImage_(package:flutter_test/src/_matchers_io.dart:31:16)
#18______MatchesReferenceImage.matchAsync_(package:flutter_test/src/matchers.dart:2154:21)
#19______expect_(package:matcher/src/expect/expect.dart:109:26)
#20_____expectLater_(package:matcher/src/expect/expect.dart:73:5)
#21_____expectLater_(package:flutter_test/src/widget_tester.dart:495:25)
#22_____main.<anonymous_closure>_(file:///Users/ksokolovskyi/dev/flutter_master/packages/flutter/test/widgets/snapshot_widget_test.dart:348:9)
<asynchronous_suspension>
#23_____testWidgetsWithLeakTracking.wrappedCallBack_(package:leak_tracker_flutter_testing/src/test_widgets.dart:126:5)
<asynchronous_suspension>
#24_____testWidgets.<anonymous_closure>.<anonymous_closure>_(package:flutter_test/src/widget_tester.dart:168:15)
<asynchronous_suspension>
#25_____TestWidgetsFlutterBinding._runTestBody_(package:flutter_test/src/binding.dart:1013:5)
<asynchronous_suspension>
#26_____StackZoneSpecification._registerCallback.<anonymous_closure>_(package:stack_trace/src/stack_zone_specification.dart:114:42)
<asynchronous_suspension>
package:matcher expect
package:flutter_test/src/widget_tester.dart 458:18 expect
package:leak_tracker_flutter_testing/src/test_widgets.dart 81:5 _tearDownTestingWithLeakTrackingFlutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.14.0-14.0.pre.377, on macOS 13.0.1 22A400 darwin-arm64, locale en-GB)
• Flutter version 3.14.0-14.0.pre.377 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 1e56af5a2e (7 hours ago), 2023-09-20 02:49:05 -0400
• Engine revision 24f7ac38df
• Dart version 3.2.0 (build 3.2.0-180.0.dev)
• DevTools version 2.28.0-dev.8
[✓] 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
a: leak trackingIssues and PRs related to memory leaks detected by leak_trackerIssues and PRs related to memory leaks detected by leak_tracker