Skip to content

Do not send traversal child semantics nodes to engine when traversal parent is missing - #193372

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
hannah-hyj:fix-190357
Oct 19, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
hannah-hyj:fix-190357

Conversation

@hannah-hyj

@hannah-hyj hannah-hyj commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

fix #190357
When an OverlayPortal (such as the one inside a Material Slider) is inside a pushed route, the route's entrance transition (e.g., FadeTransition) starts at opacity 0.0 on the initial frame.

RenderAnimatedOpacityMixin.visitChildrenForSemantics skips visiting the OverlayPortal anchor (traversalParentIdentifier), while _RenderTheater.visitChildrenForSemantics still visits the OverlayPortal's _RenderDeferredLayoutBox (traversalChildIdentifier) directly on the OverlayEntry.

Although the traversal child is excluded from its hit-test parent's childrenInTraversalOrder and childrenInHitTestOrder when its traversal parent is not in _traversalParentNodes, SemanticsOwner.sendSemanticsUpdate still serialized the traversal child via _addToUpdate. This sent an orphan SemanticsNode (not referenced by any parent in the update) to the engine, causing issues.

This PR:

  • Skips calling _addToUpdate in SemanticsOwner.sendSemanticsUpdate for nodes in a traversal child subtree whose traversal parent is missing (_isSkippedInHitTestTree).
  • Marks affected traversal children, their unmerged descendants, and their hit-test parents dirty when a traversal parent is newly registered, detaches, or changes its identifier so the nodes and hit-test child lists are updated in sync when the traversal parent enters or leaves the semantics tree.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 25, 2026
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) labels Sep 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates SemanticsNode and SemanticsOwner to skip orphan traversal children during hit testing and semantics updates when their traversal parent is detached or hidden. It also adds tests to verify that these nodes are not serialized during route transitions or opacity changes. The review feedback suggests a performance optimization in _shouldSkipInHitTest to use the private field _traversalChildIdentifier directly instead of calling the expensive getSemanticsData() method.

Comment on lines +4103 to +4104
final SemanticsNode? traversalParent =
owner!._traversalParentNodes[getSemanticsData().traversalChildIdentifier];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Calling getSemanticsData() is expensive because it allocates and compiles a new SemanticsData object on every call. Since _traversalChildIdentifier is already stored as a private field on SemanticsNode and kept up-to-date, we can directly use it here to avoid unnecessary allocations and improve performance during semantics updates.

      final SemanticsNode? traversalParent =
          owner!._traversalParentNodes[_traversalChildIdentifier];

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you! Sorry for the late response.

if (!visitedNodes.contains(childNode)) {
childNode._markDirty();
}
if (!hadSameTraversalParent) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One case that still doesn't work is nested portals (but we can fix it in a separate PR): an OverlayPortal inside another portal's overlay child (like cascading menus), when the outer anchor is hidden and shown again. With the outer anchor under Opacity 1 → 0 → 1:

  • Frame 2 (hidden): only the root is sent, so both overlay children and their descendants drop out of the engine's tree.
  • Frame 3 (shown again): the inner overlay child is re-sent and still lists its child in childrenInTraversalOrder, but that child is never re-sent.

If I read the code right, the inner anchor isn't dirty in the frame where it gets skipped, so it stays in _traversalParentNodes (L5216-5218 only removes skipped traversal parents that are dirty). When it's shown again, hadSameTraversalParent is true, so only the inner overlay child itself is marked dirty, not its descendants.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will send out a separate PR for this case

@hannah-hyj hannah-hyj added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 19, 2026
@auto-submit

auto-submit Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/193372, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…parent is missing (flutter#193372)

fix flutter#190357 
When an `OverlayPortal` (such as the one inside a Material `Slider`) is
inside a pushed route, the route's entrance transition (e.g.,
`FadeTransition`) starts at opacity `0.0` on the initial frame.

`RenderAnimatedOpacityMixin.visitChildrenForSemantics` skips visiting
the `OverlayPortal` anchor (`traversalParentIdentifier`), while
`_RenderTheater.visitChildrenForSemantics` still visits the
`OverlayPortal`'s `_RenderDeferredLayoutBox`
(`traversalChildIdentifier`) directly on the `OverlayEntry`.

Although the traversal child is excluded from its hit-test parent's
`childrenInTraversalOrder` and `childrenInHitTestOrder` when its
traversal parent is not in `_traversalParentNodes`,
`SemanticsOwner.sendSemanticsUpdate` still serialized the traversal
child via `_addToUpdate`. This sent an orphan `SemanticsNode` (not
referenced by any parent in the update) to the engine, causing issues.


This PR:
- Skips calling `_addToUpdate` in `SemanticsOwner.sendSemanticsUpdate`
for nodes in a traversal child subtree whose traversal parent is missing
(`_isSkippedInHitTestTree`).
- Marks affected traversal children, their unmerged descendants, and
their hit-test `parent`s dirty when a traversal parent is newly
registered, detaches, or changes its identifier so the nodes and
hit-test child lists are updated in sync when the traversal parent
enters or leaves the semantics tree.


## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant in-code documentation (doc comments with
`///`).
- [ ] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Porthorion added a commit to Porthorion/Navis that referenced this pull request Nov 5, 2026
…279)

Material's Slider always wraps its value indicator in an OverlayPortal. In
a pushed route Flutter 3.47 then sends the engine a semantics node that no
parent lists as a child (flutter/flutter#190357). The macOS and Windows
accessibility bridges reject it, stay failed, and freeze their native tree
on stale nodes; a later pointer move can then read a freed node and crash
(flutter/flutter#193588). Part of #267.

NavisSlider wraps Slider in its own Overlay.wrap(alwaysSizeToContent,
Clip.none), which keeps the portal's semantics inside the slider. All 17
Slider sites use it and an architecture test forbids a bare Slider in lib.
The wrap goes away once a stable Flutter ships flutter/flutter#193372.

Co-authored-by: khalifa <[email protected]>
Co-authored-by: Claude Sonnet <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] A Slider inside a pushed route serializes an orphan semantics node, permanently freezing the accessibility tree

2 participants