Skip to content

Add versioning and validation metadata to Impeller shader blobs to ensure forward compatibility #172899

@Hellomik2002

Description

@Hellomik2002

Use case

Runtime Shaders

Proposal

Currently, shader blobs emitted by impellerc do not include any versioning or validation metadata. This creates a risk when:

  • Applications persist these blobs (e.g., to ship precompiled shaders),
  • But impellerc or the Impeller runtime changes assumptions about layout, encoding, or expectations.

Such mismatches could lead to runtime crashes, undefined behavior, or difficult-to-diagnose bugs due to incompatible blobs being loaded.

This issue was raised during review of flutter/flutter#168294, which introduces support for loading precompiled Impeller shaders from in-memory blobs.

The same problem exists with the fragment program API, which also accepts external shader inputs.

Proposal

We should introduce in impellerc:

  • A version tag (semantic or numeric) embedded in each shader blob
  • A validation header or magic number for early failure detection
  • Possibly a checksum or hash for corruption detection
  • Runtime blob consumers (e.g., RuntimeStage, fragment program loader) should verify this metadata before accepting the blob

By doing this once in impellerc, we ensure both the mobile APIs and fragment program APIs avoid future forward-compatibility issues.


Related PR: #168294

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttere: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.r: fixedIssue is closed as already fixed in a newer versionteam-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