-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I was debugging flakes in flutter_desktop_darwin_unittests, and I noticed that the tests were leaking file descriptors and other resources.
Each test allocates a FlutterEngine and then drops its reference. But theseFlutterEngine instances are never deleted.
I traced this to the call to setUpPlatformViewChannel in FlutterEngine.initWithName (https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L267)
IIUC this is causing the _platformViewsChannel to hold a reference to the FlutterEngine, thus creating a cycle.
There is a TODO implying that there should be another level of indirection between the channel's binaryMessenger and the FlutterEngine reference (https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L488)