Skip to content

[a11y] Null check in PipelineOwner.flushSemantics (geometry! at object.dart:6271 / 6413) from a stale firstAncestorNodeWithCleanGeometry #195316

Description

@Lopution

Steps to reproduce

  1. 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).
  2. 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

  1. added
    in triage
    framework
    a: accessibility
    team-accessibility
    and removed
    in triage
    on Oct 26, 2026
  2. mbcorona commented on Oct 26, 2026

    @mbcorona
    Member

    Hi @Lopution, thanks for the report.
    Routing to team-accessibility for evaluation.

  3. added
    triaged-accessibility
    P2
    on Oct 28, 2026
  4. added 3 commits that reference this issue on Nov 2, 2026
  5. EricGogoX commented on Nov 3, 2026

    @EricGogoX

    Adding production signal from iOS (the existing traces here are Android), in case it helps prioritise #192724.

    • Flutter stable 3.47.0, release (AOT) build of a production app
    • Crashlytics, one week: 27 users / 27 fatal events (~0.23% of our Flutter users), mostly iOS 27.0.1 and iOS 26.x, on recent iPhone Pro Max models
    • Exactly one event per affected user, which fits an accessibility service (VoiceOver etc.) being on, since we never force semantics on ourselves
    • Symbolicated top frame: _RenderObjectSemantics._buildSemanticsSubtree at rendering/object.dart:6271, which is the geometry!.hidden read, called from PipelineOwner.flushSemantics (ensureSemanticsNode is inlined in release)
    FlutterError: Null check operator used on a null value
      _RenderObjectSemantics._buildSemanticsSubtree (object.dart)
      PipelineOwner.flushSemantics (object.dart)
    

    This matches the stale firstAncestorNodeWithCleanGeometry path described in #192724. In our 3.47.0 SDK the guarded branch at object.dart:1616-1620 still reads the cache without computeAncestorInfo(treeShapeToken). We have no app-side workaround and are waiting on this fix to ship in stable.

  6. added a commit that references this issue on Nov 24, 2026
    1c858ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2a: accessibilityframeworkteam-accessibilitytriaged-accessibility

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions