Skip to content

iOS FlutterTextureRegistry should be a proxy, not the engine itself #102990

@stuartmorgan-g

Description

@stuartmorgan-g

The general model on iOS (I believe; it's possible the internals have changed here enough since I last looked that this is no longer true and there is enough indirection that I can't quickly tell from the source) is that the engine indirectly owns plugin instances via addMethodCallDelegate: (which despite the name, creates a strong reference to the delegate, which is the plugin itself).

This makes having the FlutterTextureRegistry returned by [registrar textures] be the engine itself problematic, because if the plugin retains the texture registrar there's a cycle. It's easy for developers to do this, and it's not even clear from the API that they shouldn't.

See #102966 for an example.

We should have a proxy object with a weak reference back to the engine serve as the texture registry object that is returned instead.

/cc @gaaclarke; IIRC you fixed this same problem with the binary messenger a while ago.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectengineflutter/engine related. See also e: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions