Skip to content

FlutterMetalTexture destruction_callback not called when fetched via FlutterMetalRendererConfig.get_next_drawable_callback #116381

@cbracken

Description

@cbracken

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.

Metadata

Metadata

Assignees

Labels

e: embedderUsers of the Embedder APIengineflutter/engine related. See also e: labels.perf: memoryPerformance issues related to memory

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions