Skip to content

[Embedder API] Fix ABI stability of the update semantics API #121176

@loic-sharma

Description

@loic-sharma

See go/flutter-semantics-abi.

Work

Background

Flutter 3.7 introduced a new embedder API for semantic updates: flutter/engine#37129. The Tizen embedder has migrated to this new API: flutter-tizen/embedder#24.

The embedder API should provide full forward and backward ABI compatibility. However, adding new members to FlutterSemanticsNode or FlutterSemanticsCustomAction may cause external embedders to crash if they update the engine without recompiling.

For example:

FlutterSemanticsUpdate update = ...;
FlutterSemanticsNode first = updates.nodes[0];
FlutterSemanticsNode second = updates.nodes[1]; // BAD! This could crash

The array indexing might crash if the external embedder wasn't recompiled after an engine update. Instead, external embedders must determine the size of FlutterSemanticsNode or FlutterSemanticsCustomAction using their struct_size member. Something like:

FlutterSemanticsUpdate update = ...;
FlutterSemanticsNode first = updates.nodes[0];
FlutterSemanticsNode second = static_cast<FlutterSemanticsNode*>(
    static_cast<char*>(update.nodes) + 1 * first.struct_size);

This problem would've been avoided if FlutterSemanticsUpdate.nodes or FlutterSemanticsUpdate.custom_actions were arrays of pointers to structs instead of arrays of structs.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: desktopRunning on desktope: embedderUsers of the Embedder APIplatform-macBuilding on or for macOS specificallyplatform-windowsBuilding on or for Windows specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions