Repository navigation
Description
Steps to reproduce
- Build a
Semantics(identifier: ...)node whose identifier changes while nothing else on that node changes (label, flags and actions stay the same). - A common real-world case: a
ListView.builderwhose items are not keyed, where each item isSemantics(identifier: 'row_$name', explicitChildNodes: true, child: ListTile(title: Text(name), onTap: ...)), and the list re-orders. Each row's element is reused by index: theTextlabel updates, but the container node only gets a new identifier. - Inspect the platform accessibility tree (Xcode Accessibility Inspector / XCUITest / Appium / Maestro on iOS;
uiautomator dumpresource-id on Android), or run the test below, which records what the framework sends to the engine.
Expected results
The platform node carries the new identifier, as the framework's semantics tree does (tester.getSemantics(...), Widget Inspector).
Actual results
The engine never receives the new identifier: the platform node keeps the old one. After a re-order the identifiers no longer match the rows they are on (row 1 shows B but has id row_A), so a UI test that selects by identifier taps the wrong row.
Cause: SemanticsNode.updateWith assigns _identifier = config.identifier, but _isDifferentFromCurrentSemanticAnnotation does not compare identifier, so the node is not marked dirty and SemanticsOwner.sendSemanticsUpdate skips it. When the label also changes on the same node, the update goes out and carries the new identifier, which is likely why this looks fine in most cases.
#165562 reported the same symptom and was closed after a check in the Widget Inspector. The inspector reads the framework tree, which is correct. The engine side is not. On master today _isDifferentFromCurrentSemanticAnnotation still has no identifier check.
Possible fix: add _identifier != config.identifier to _isDifferentFromCurrentSemanticAnnotation, as #185707 did for customSemanticsActions.
Related: #195755 is a similar stale-semantics bug for TextSpan.semanticsIdentifier and semanticsLabel, at another layer: there TextSpan.compareTo skips the update, so the framework tree is stale too. Its fix (#195756) does not touch SemanticsNode.
Code sample
Test that records what is sent to the engine
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
/// Identifier of every node the framework sent to the engine, by node id.
final Map<int, String> sentIdentifiers = <int, String>{};
class _SpySemanticsUpdateBuilder implements ui.SemanticsUpdateBuilder {
@override
dynamic noSuchMethod(Invocation invocation) {
if (invocation.memberName == #updateNode) {
sentIdentifiers[invocation.namedArguments[#id] as int] = invocation.namedArguments[#identifier] as String;
return null;
}
if (invocation.memberName == #build) {
return ui.SemanticsUpdateBuilder().build();
}
return null;
}
}
class _SpyBinding extends AutomatedTestWidgetsFlutterBinding {
@override
ui.SemanticsUpdateBuilder createSemanticsUpdateBuilder() => _SpySemanticsUpdateBuilder();
}
void main() {
_SpyBinding();
testWidgets('a node whose identifier changes is sent to the engine with the new identifier', (tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
Widget app(String identifier) => Directionality(
textDirection: TextDirection.ltr,
child: Semantics(
identifier: identifier,
explicitChildNodes: true,
child: const Text('label'),
),
);
await tester.pumpWidget(app('first'));
expect(sentIdentifiers.values, contains('first'));
final int id = sentIdentifiers.entries.firstWhere((e) => e.value == 'first').key;
await tester.pumpWidget(app('second'));
expect(tester.getSemantics(find.text('label')).parent!.identifier, 'second'); // framework tree: updated
expect(sentIdentifiers[id], 'second'); // engine: still 'first'
handle.dispose();
});
}Result on 3.47.9: the framework-tree expectation passes, and the engine one fails with Expected: 'second' Actual: 'first'.
Sample app (re-ordering list)
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: ReorderingList()));
class ReorderingList extends StatefulWidget {
const ReorderingList({super.key});
@override
State<ReorderingList> createState() => _ReorderingListState();
}
class _ReorderingListState extends State<ReorderingList> {
List<String> names = <String>['A', 'B', 'C'];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Identifier repro')),
floatingActionButton: FloatingActionButton(
onPressed: () => setState(() => names = names.reversed.toList()),
child: const Icon(Icons.swap_vert),
),
body: ListView.builder(
itemCount: names.length,
itemBuilder: (BuildContext context, int index) => Semantics(
identifier: 'row_${names[index]}',
explicitChildNodes: true,
child: ListTile(title: Text(names[index]), onTap: () {}),
),
),
);
}
}Tap the button, then inspect the rows: the row showing C still has identifier row_A. Keying the items (key: ValueKey(names[index])) avoids it.
Screenshots or Video
None. See the test above.
Logs
None.
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.47.9, on macOS 27.2 26B123 darwin-arm64, locale en-GB) [2.0s]
• Flutter version 3.47.9 on channel stable at /Users/andrea/fvm/versions/3.47.9
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c197ca5199 (2 weeks ago), 2026-10-29 10:10:20 -0400
• Engine revision 89c39edfdf
• Dart version 3.13.7
• DevTools version 2.60.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.5s]
• Android SDK at /Users/andrea/Library/Android/sdk
• Emulator version 37.1.8.0 (build_id 15828024) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 27.2) [3.2s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 27B52
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [7ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (3 available) [12.7s]
• iPhone (mobile) • <udid> • ios • iOS 27.2 24B119
• macOS (desktop) • macos • darwin-arm64 • macOS 27.2 26B123 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 157.0.8103.52
[✓] Network resources [341ms]
• All expected network resources are available.
• No issues found!
Activity
mbcorona commentedon Nov 12, 2026
Thanks for the precise report and the test @andrea689.
Routing to the accessibility team.
Send a semantics update when only the identifier changes (flutter#196460