Skip to content

Allow loading fragment shaders from custom asset bundles #167404

@Stumblinbear

Description

@Stumblinbear

Use case

As it currently stands, fragment shaders appear to be loaded outside of the typical method of loading assets. They seem to sidestep the defined DefaultAssetBundle as well as the rootBundle, opting to fetch the shader directly from an asset manager in C++ instead. I have not found a way to modify this behavior.

We have built a custom embedding, and we make our assets available via our own custom asset bundle implementation, but if we want to use any custom shaders we'd have to ship those via the built-in asset bundling method instead. Shaders don't even seem to use the asset platform channel, so making it available through that's not doable, either.

Our asset bundle does include the compiled shader, the Flutter engine just cannot find it.

Correct me if I'm wrong, of course, but it seems there's no way to load shaders any other way.

Proposal

Updating it to search the root asset bundle would likely be a breaking change, and it would require access to BuildContext in order to get the current DefaultAssetBundle. The fragment program load function could take an optional asset bundle argument and use that if supplied.

I'm unsure of the specifics of the implementation that may make this solution infeasible

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions