-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
When a new viewType is passed into AppKitView, then _DarwinViewState calls _createNewUiKitView, which creates a new FocusNode and does not dispose the old one.
Test to reveal the leak:
testWidgetsWithLeakTracking('_DarwinViewState leak', (WidgetTester tester) async {
final FakeMacosPlatformViewsController viewsController = FakeMacosPlatformViewsController();
viewsController.registerViewType('webview');
viewsController.registerViewType('maps');
await tester.pumpWidget(
const Center(
child: SizedBox(
width: 200.0,
height: 100.0,
child: AppKitView(viewType: 'webview', layoutDirection: TextDirection.ltr),
),
),
);
await tester.pumpWidget(
const Center(
child: SizedBox(
width: 200.0,
height: 100.0,
child: AppKitView(viewType: 'maps', layoutDirection: TextDirection.ltr),
),
),
);
});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:
FocusNode:
test: _DarwinViewState leak
identityHashCode: 927710690
package:matcher expect
package:flutter_test/src/widget_tester.dart 458:18 expect
package:leak_tracker_flutter_testing/src/test_widgets.dart 81:5 _tearDownTestingWithLeakTracking
===== asynchronous gap ===========================
dart:async _CustomZone.registerBinaryCallback
package:leak_tracker_flutter_testing/src/test_widgets.dart 59:9 configureLeakTrackingTearDown.<fn>Flutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.14.0-14.0.pre.341, on macOS 13.0.1 22A400 darwin-arm64, locale en-GB)
• Flutter version 3.14.0-14.0.pre.341 on channel master at /Users/ksokolovskyi/dev/flutter_master
• Upstream repository git@github.com:ksokolovskyi/flutter.git
• FLUTTER_GIT_URL = git@github.com:ksokolovskyi/flutter.git
• Framework revision 2337c64d0c (3 hours ago), 2023-09-18 13:13:37 +0200
• Engine revision 4107ee0dc8
• Dart version 3.2.0 (build 3.2.0-173.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