-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
FlutterRendererConfig's get_next_drawable_callback member holds a callback used by the embedder API to request a drawable; in the case of Metal, this drawable is a FlutterMetalTexture.
FlutterMetalTexture includes a destruction_callback member which should be called when it's safe to release resources associated with the FlutterMetalTexture. This callback is not currently invoked for textures returned via FlutterRendererConfig.get_next_drawable_callback; instead we unpack the returned struct and pass it on. See here:
https://github.com/flutter/engine/blob/303e26e96561d9b76f2344e97a5fc32eb6dfdb9a/shell/platform/embedder/embedder.cc#L468-L481
In the compositor codepath, we do create an SkSurface that triggers the destruction callback, here:
https://github.com/flutter/engine/blob/303e26e96561d9b76f2344e97a5fc32eb6dfdb9a/shell/platform/embedder/embedder.cc#L868-L881
While the primary purpose of FlutterRendererConfig.get_next_drawable_callback is to get a hold of a texture, and SkSurface will release it, the embedder may need to release other resources allocated as part of texture creation, so it's important we trigger FlutterMetalTexture.destruction_callback as part of that codepath.
Identified in flutter/engine#37789.