Sitelet https://github.com/flutter/flutter/pull/191620
Skip to content

Clean up semantics code - #191620

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
chunhtai:semantics-clean-up
Sep 1, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
chunhtai:semantics-clean-up

Conversation

@chunhtai

Copy link
Copy Markdown
Contributor

Some bug I found during implementing accessibilityOpaque. Separated them out to this pr for easier review

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 Aug 24, 2026
@chunhtai
chunhtai requested a review from hannah-hyj August 24, 2026 23:04
@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 Aug 24, 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 semantics handling in Flutter. It conditionally clears geometry when a _RenderObjectSemantics's parent data changes and was previously dirty, and avoids marking SemanticsConfiguration as annotated when accessibilityFocusBlockType is set to its existing value. Tests are added to verify both behaviors. The reviewer suggests always clearing geometry when parentData changes to prevent potential edge cases with stale cached geometry.

Comment on lines +6091 to +6097
final bool wasParentDataDirty = parentDataDirty;
// Parent data changes may result in node formation changes.
markNeedsBuild();
parentData = newParentData;
if (wasParentDataDirty) {
geometry = null;
}

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.

high

Instead of conditionally clearing geometry only when wasParentDataDirty is true, it is safer and more robust to always clear geometry whenever parentData changes.

Why?

_SemanticsFragment.geometry is a cached value representing the transform and rect of this fragment relative to its semantics ancestors. When parentData (the semantics parent relation) changes, it means this fragment has been attached, detached, or moved to a different parent fragment. Any such structural change in the semantics tree invalidates the cached geometry.

If we only clear geometry when wasParentDataDirty is true, we can run into edge cases where:

  1. An ancestor's transform changes while this fragment is detached (so parentDataDirty is false for this fragment).
  2. When the fragment rejoins, parentData changes from null to the new parent data.
  3. Since wasParentDataDirty is false, geometry is not cleared, and the old cached geometry (which does not reflect the ancestor's new transform) is incorrectly reused.

Always setting geometry = null when parentData changes ensures that the geometry is correctly recomputed upon rejoining or moving.

    // Parent data changes may result in node formation changes.
    markNeedsBuild();
    parentData = newParentData;
    geometry = null;

@hannah-hyj hannah-hyj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit

auto-submit Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/191620, 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.

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 1, 2026
Merged via the queue into flutter:master with commit 5474d44 Sep 1, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 1, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 1, 2026
flutter/flutter@c8c5e3b...0cbd1a4

2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 6be7f8547c3c to 3911a1fe7f7a (1 revision) (flutter/flutter#192110)
2026-09-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from EPzxifoyt36b5qiBy... to idslm9FikVLy2K_A-... (flutter/flutter#192104)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 47df2ae3226c to 6be7f8547c3c (1 revision) (flutter/flutter#192103)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from e22ebf131e44 to 47df2ae3226c (4 revisions) (flutter/flutter#192099)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 5489a16a5998 to e22ebf131e44 (5 revisions) (flutter/flutter#192093)
2026-09-01 bkonyi@google.com [flutter_tools] Safely handle broken symlinks and existing files during plugin symlink creation (flutter/flutter#191496)
2026-09-01 97480502+b-luk@users.noreply.github.com Support wide gamut colors in gradient_generator's CreateGradientTexture (flutter/flutter#191980)
2026-09-01 47866232+chunhtai@users.noreply.github.com Clean up semantics code (flutter/flutter#191620)
2026-08-31 49662805+jesskuras@users.noreply.github.com Add website documentation item to PR pre-launch checklist (flutter/flutter#192080)
2026-08-31 kiran@kryali.com [windows] Fix null-deref in HostWindowPopup::UpdatePosition (Fixes #191478) (flutter/flutter#191479)
2026-08-31 47866232+chunhtai@users.noreply.github.com Removes deprecated ignoreSemantics parementers (flutter/flutter#191493)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from b319095e317b to 9164def35347 (1 revision) (flutter/flutter#192073)
2026-08-31 112751483+shivanshu877@users.noreply.github.com test: dynamic _tapOutside helper for TapRegion navigation tests (flutter/flutter#185397)
2026-08-31 git@reb0.org [Windows] fix: Remove quotes from compiler warning suppression (flutter/flutter#190873)
2026-08-31 47866232+chunhtai@users.noreply.github.com Migrate to listen package (flutter/flutter#189111)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 15db98a90bbd to 5489a16a5998 (2 revisions) (flutter/flutter#192070)
2026-08-31 110348311+Devasy@users.noreply.github.com Add regression test for plugin compileSdkExtension warning (flutter/flutter#191281)
2026-08-31 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in platform view benchmarks and integration tests (flutter/flutter#191908)
2026-08-31 matt.boetger@gmail.com Documentation and script for Gradle Distribution cache for CI (flutter/flutter#190323)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 5549c93c9a1c to 15db98a90bbd (2 revisions) (flutter/flutter#192068)
2026-08-31 engine-flutter-autoroll@skia.org Roll Packages from cd4cdd0 to d642322 (7 revisions) (flutter/flutter#192063)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from 48f641e8b249 to b319095e317b (1 revision) (flutter/flutter#192061)
2026-08-31 269567208+reidbaker-agent@users.noreply.github.com [tool] Migrate dev/tools from dart_skills_lint to skills_lint package (flutter/flutter#191997)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12712)

flutter/flutter@c8c5e3b...0cbd1a4

2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 6be7f8547c3c to 3911a1fe7f7a (1 revision) (flutter/flutter#192110)
2026-09-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from EPzxifoyt36b5qiBy... to idslm9FikVLy2K_A-... (flutter/flutter#192104)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 47df2ae3226c to 6be7f8547c3c (1 revision) (flutter/flutter#192103)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from e22ebf131e44 to 47df2ae3226c (4 revisions) (flutter/flutter#192099)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 5489a16a5998 to e22ebf131e44 (5 revisions) (flutter/flutter#192093)
2026-09-01 bkonyi@google.com [flutter_tools] Safely handle broken symlinks and existing files during plugin symlink creation (flutter/flutter#191496)
2026-09-01 97480502+b-luk@users.noreply.github.com Support wide gamut colors in gradient_generator's CreateGradientTexture (flutter/flutter#191980)
2026-09-01 47866232+chunhtai@users.noreply.github.com Clean up semantics code (flutter/flutter#191620)
2026-08-31 49662805+jesskuras@users.noreply.github.com Add website documentation item to PR pre-launch checklist (flutter/flutter#192080)
2026-08-31 kiran@kryali.com [windows] Fix null-deref in HostWindowPopup::UpdatePosition (Fixes #191478) (flutter/flutter#191479)
2026-08-31 47866232+chunhtai@users.noreply.github.com Removes deprecated ignoreSemantics parementers (flutter/flutter#191493)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from b319095e317b to 9164def35347 (1 revision) (flutter/flutter#192073)
2026-08-31 112751483+shivanshu877@users.noreply.github.com test: dynamic _tapOutside helper for TapRegion navigation tests (flutter/flutter#185397)
2026-08-31 git@reb0.org [Windows] fix: Remove quotes from compiler warning suppression (flutter/flutter#190873)
2026-08-31 47866232+chunhtai@users.noreply.github.com Migrate to listen package (flutter/flutter#189111)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 15db98a90bbd to 5489a16a5998 (2 revisions) (flutter/flutter#192070)
2026-08-31 110348311+Devasy@users.noreply.github.com Add regression test for plugin compileSdkExtension warning (flutter/flutter#191281)
2026-08-31 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in platform view benchmarks and integration tests (flutter/flutter#191908)
2026-08-31 matt.boetger@gmail.com Documentation and script for Gradle Distribution cache for CI (flutter/flutter#190323)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 5549c93c9a1c to 15db98a90bbd (2 revisions) (flutter/flutter#192068)
2026-08-31 engine-flutter-autoroll@skia.org Roll Packages from cd4cdd0 to d642322 (7 revisions) (flutter/flutter#192063)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from 48f641e8b249 to b319095e317b (1 revision) (flutter/flutter#192061)
2026-08-31 269567208+reidbaker-agent@users.noreply.github.com [tool] Migrate dev/tools from dart_skills_lint to skills_lint package (flutter/flutter#191997)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12712)

flutter/flutter@c8c5e3b...0cbd1a4

2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 6be7f8547c3c to 3911a1fe7f7a (1 revision) (flutter/flutter#192110)
2026-09-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from EPzxifoyt36b5qiBy... to idslm9FikVLy2K_A-... (flutter/flutter#192104)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 47df2ae3226c to 6be7f8547c3c (1 revision) (flutter/flutter#192103)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from e22ebf131e44 to 47df2ae3226c (4 revisions) (flutter/flutter#192099)
2026-09-01 engine-flutter-autoroll@skia.org Roll Skia from 5489a16a5998 to e22ebf131e44 (5 revisions) (flutter/flutter#192093)
2026-09-01 bkonyi@google.com [flutter_tools] Safely handle broken symlinks and existing files during plugin symlink creation (flutter/flutter#191496)
2026-09-01 97480502+b-luk@users.noreply.github.com Support wide gamut colors in gradient_generator's CreateGradientTexture (flutter/flutter#191980)
2026-09-01 47866232+chunhtai@users.noreply.github.com Clean up semantics code (flutter/flutter#191620)
2026-08-31 49662805+jesskuras@users.noreply.github.com Add website documentation item to PR pre-launch checklist (flutter/flutter#192080)
2026-08-31 kiran@kryali.com [windows] Fix null-deref in HostWindowPopup::UpdatePosition (Fixes #191478) (flutter/flutter#191479)
2026-08-31 47866232+chunhtai@users.noreply.github.com Removes deprecated ignoreSemantics parementers (flutter/flutter#191493)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from b319095e317b to 9164def35347 (1 revision) (flutter/flutter#192073)
2026-08-31 112751483+shivanshu877@users.noreply.github.com test: dynamic _tapOutside helper for TapRegion navigation tests (flutter/flutter#185397)
2026-08-31 git@reb0.org [Windows] fix: Remove quotes from compiler warning suppression (flutter/flutter#190873)
2026-08-31 47866232+chunhtai@users.noreply.github.com Migrate to listen package (flutter/flutter#189111)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 15db98a90bbd to 5489a16a5998 (2 revisions) (flutter/flutter#192070)
2026-08-31 110348311+Devasy@users.noreply.github.com Add regression test for plugin compileSdkExtension warning (flutter/flutter#191281)
2026-08-31 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in platform view benchmarks and integration tests (flutter/flutter#191908)
2026-08-31 matt.boetger@gmail.com Documentation and script for Gradle Distribution cache for CI (flutter/flutter#190323)
2026-08-31 engine-flutter-autoroll@skia.org Roll Skia from 5549c93c9a1c to 15db98a90bbd (2 revisions) (flutter/flutter#192068)
2026-08-31 engine-flutter-autoroll@skia.org Roll Packages from cd4cdd0 to d642322 (7 revisions) (flutter/flutter#192063)
2026-08-31 engine-flutter-autoroll@skia.org Roll Dart SDK from 48f641e8b249 to b319095e317b (1 revision) (flutter/flutter#192061)
2026-08-31 269567208+reidbaker-agent@users.noreply.github.com [tool] Migrate dev/tools from dart_skills_lint to skills_lint package (flutter/flutter#191997)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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.

2 participants