Repository navigation
Description
Steps to reproduce
- Save the code sample below as a widget test (it is the test from Fix null check crash in flushSemantics from a stale ancestor geometry cache #192724, unchanged).
- Run it on stable 3.47.7:
flutter test.
The same crash reaches users of a release Android app with an accessibility service enabled, where a modal sheet or dialog (BlockSemantics) is over a page whose semantics change underneath it.
Expected results
PipelineOwner.flushSemantics completes, and the semantics tree is correct once the barrier goes away.
Actual results
flushSemantics throws Null check operator used on a null value:
#0 _RenderObjectSemantics._buildSemanticsSubtree (package:flutter/src/rendering/object.dart:6271:61)
#1 _RenderObjectSemantics.ensureSemanticsNode (package:flutter/src/rendering/object.dart:6201:7)
#2 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1636:18)
#3 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1653:15)
#4 AutomatedTestWidgetsFlutterBinding.drawFrame (package:flutter_test/src/binding.dart:2445:35)
In production the same call path fails at two geometry! reads, depending on whether the target node was already built. Below are two field traces from a release build (Android, arm64, accessibility service on), symbolized against rebuilt debug info whose .text matches the shipped libapp.so byte for byte. App frames are cut.
Trace 1, the target node had not been built yet:
#0 _RenderObjectSemantics._updateSemanticsNodeGeometry (package:flutter/src/rendering/object.dart:6413:53)
#1 _RenderObjectSemantics._produceSemanticsNode (package:flutter/src/rendering/object.dart:6315:5)
#2 _RenderObjectSemantics._buildSemantics (package:flutter/src/rendering/object.dart:6227:7)
#3 _RenderObjectSemantics.ensureSemanticsNode (package:flutter/src/rendering/object.dart:6194:7)
#4 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1636:18)
#5 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1653:15)
Trace 2, the target node was already built (the same frames as the test):
#0 _RenderObjectSemantics._buildSemanticsSubtree (package:flutter/src/rendering/object.dart:6271:61)
#1 _RenderObjectSemantics.ensureSemanticsNode (package:flutter/src/rendering/object.dart:6201:7)
#2 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1636:18)
#3 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1653:15)
#192724 explains the cause and fixes it. In the branch for a node whose geometry became invisible, parentInSemanticsTree.firstAncestorNodeWithCleanGeometry is read without calling computeAncestorInfo(treeShapeToken) first. The value can be left over from an earlier flush and point at a node whose geometry has since been cleared, so ensureSemanticsNode() runs on a node with geometry == null.
The error is caught by FlutterError.reportError after the frame has been composited, so the app does not die. But that flush stops partway: _nodesNeedingSemanticsUpdate was already cleared, the remaining nodes are never processed, and sendSemanticsUpdate() is skipped, so the platform keeps a stale tree until those nodes change again.
This issue is filed so #192724 has an issue to link to (as requested in that PR). Related: #184036 (fixed by #184226, a different path) and #189908 (an owner! read in the same flush).
Code sample
Code sample
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('a node that becomes invisible while its branch is blocked does not '
'crash when an ancestor geometry cache is stale', (WidgetTester tester) async {
final blocked = ValueNotifier<bool>(false);
addTearDown(blocked.dispose);
final outerLabel = ValueNotifier<String>('outer');
addTearDown(outerLabel.dispose);
final offset = ValueNotifier<double>(0.0);
addTearDown(offset.dispose);
final middleLabel = ValueNotifier<String>('middle');
addTearDown(middleLabel.dispose);
final innerLabel = ValueNotifier<String>('inner');
addTearDown(innerLabel.dispose);
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: ValueListenableBuilder<bool>(
valueListenable: blocked,
builder: (BuildContext context, bool isBlocked, Widget? page) {
return Stack(
children: <Widget>[
page!,
if (isBlocked) const BlockSemantics(child: SizedBox.expand()),
],
);
},
child: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 200.0,
height: 200.0,
// "outer" is a semantics boundary and a relayout boundary.
child: ValueListenableBuilder<String>(
valueListenable: outerLabel,
builder: (BuildContext context, String label, Widget? child) {
return Semantics(
container: true,
explicitChildNodes: true,
label: label,
child: child,
);
},
// The transform does not contribute to the semantics tree, so
// changing it clears the geometry of "middle".
child: ValueListenableBuilder<double>(
valueListenable: offset,
builder: (BuildContext context, double dx, Widget? child) {
return Transform.translate(offset: Offset(dx, 0.0), child: child);
},
child: Align(
alignment: Alignment.topLeft,
// "middle" forms a semantics node but is not a boundary.
child: ValueListenableBuilder<String>(
valueListenable: middleLabel,
builder: (BuildContext context, String label, Widget? child) {
return Semantics(label: label, child: child);
},
// "inner" is a semantics boundary with an empty rect.
child: ValueListenableBuilder<String>(
valueListenable: innerLabel,
builder: (BuildContext context, String label, Widget? child) {
return Semantics(
container: true,
label: label,
child: const SizedBox.shrink(),
);
},
),
),
),
),
),
),
),
),
),
);
blocked.value = true;
await tester.pump();
offset.value = 1.0;
middleLabel.value = 'middle 2';
await tester.pump();
outerLabel.value = 'outer 2';
offset.value = 2.0;
innerLabel.value = 'inner 2';
await tester.pump();
expect(tester.takeException(), isNull);
blocked.value = false;
await tester.pump();
expect(tester.takeException(), isNull);
expect(find.bySemanticsLabel('outer 2'), findsOneWidget);
expect(find.bySemanticsLabel('middle 2'), findsOneWidget);
});
}Screenshots or Video
No response
Logs
The test's stack trace is under Actual results; the rest of the output is the standard test failure.
Flutter Doctor output
Doctor output
Flutter 3.47.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision abaf9c5237 • 2026-10-08
Engine • hash d8a2d6c768c334d53e16277f837970ffa1e2de81 (revision deb287481e) • 2026-10-07
Tools • Dart 3.13.5 • DevTools 2.60.0
Activity
mbcorona commentedon Oct 26, 2026
Hi @Lopution, thanks for the report.
Routing to team-accessibility for evaluation.
build(web): carry flutter/flutter#192724 in the builder image (Refs #746
build(web): carry flutter/flutter#192724 in the builder image (Refs #746
build(web): carry flutter/flutter#192724 in the builder image (Refs #746
EricGogoX commentedon Nov 3, 2026
Adding production signal from iOS (the existing traces here are Android), in case it helps prioritise #192724.
_RenderObjectSemantics._buildSemanticsSubtreeatrendering/object.dart:6271, which is thegeometry!.hiddenread, called fromPipelineOwner.flushSemantics(ensureSemanticsNodeis inlined in release)This matches the stale
firstAncestorNodeWithCleanGeometrypath described in #192724. In our 3.47.0 SDK the guarded branch atobject.dart:1616-1620still reads the cache withoutcomputeAncestorInfo(treeShapeToken). We have no app-side workaround and are waiting on this fix to ship in stable.Fix null check crash in flushSemantics from a stale ancestor geometry…
fix(play): drop stale semantics of hidden pages under the player [BUG…
fix(play): semantics crash on seek — Flutter stale geometry cache und…
docs: PostHog bug 1 is upstream Flutter; record #711 merge commit in …
docs: PostHog bug 1 is upstream Flutter; record #711 merge commit in …
docs: PostHog bug 1 is upstream Flutter; record #711 merge commit in …