Skip to content

Update merge semantics logic to merge sibling nodes#183745

Merged
auto-submit[bot] merged 8 commits into
flutter:masterfrom
chunhtai:issues/160281
Apr 29, 2026
Merged

Update merge semantics logic to merge sibling nodes#183745
auto-submit[bot] merged 8 commits into
flutter:masterfrom
chunhtai:issues/160281

Conversation

@chunhtai

@chunhtai chunhtai commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

fixes #160281

The issue is that merge semantics flag is set on semantics node. and is process only when sending semantics node to engine.

This become a issue when a render object creates more than one semantics node (self node + sibling nodes) to be attached to parent semantics node. If this renderobject has isMergingSemanticsOfDescendants = true, the end result should be merging all nodes into one semantics node to be attached to parent. Currently the renderobject will set the flag isMergingSemanticsOfDescendants only on the self node which causes sibling nodes to not merge together.

To correctly fix the issue, the renderobject will create a new node to host both self node and sibling nodes. it will then set isMergingSemanticsOfDescendants on this new node

Pre-launch Checklist

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

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

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Mar 16, 2026
@chunhtai chunhtai marked this pull request as draft March 16, 2026 18:26

@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 the semantics merging logic in _RenderObjectSemantics._buildSemanticsSubtree to handle sibling nodes when isMergingSemanticsOfDescendants is true. A new "housing" node is introduced to wrap children before merging. My review identified a block of unreachable code in the new logic that should be removed.

Comment thread packages/flutter/lib/src/rendering/object.dart Outdated
@github-actions github-actions Bot added the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Mar 16, 2026
@chunhtai chunhtai added the CICD Run CI/CD label Mar 16, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Mar 19, 2026
@chunhtai chunhtai added the CICD Run CI/CD label Mar 19, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Mar 19, 2026
children: <TestSemantics>[
TestSemantics.rootChild(label: 'parent\n2'),
TestSemantics.rootChild(label: '1\n3'),
TestSemantics.rootChild(label: 'parent\n2'),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sibling nodes doesn't promise hittest order because they can be arbitrary renderobjects in the subtree merge together

@chunhtai chunhtai added the CICD Run CI/CD label Mar 20, 2026
@chunhtai chunhtai marked this pull request as ready for review March 20, 2026 17:12

@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 the semantics merging logic to correctly merge sibling nodes, addressing an issue where MergeSemantics failed to combine properties from TextField's prefix and suffix. The core change in _RenderObjectSemantics introduces a new approach for nodes with isMergingSemanticsOfDescendants, where an inner SemanticsNode is used to group the node's own semantics with its siblings for merging. This is supported by refactoring how sibling nodes are collected and added to the semantics tree. A new test is added to verify the fix, and an existing test is adjusted for the new node ordering.

Comment thread packages/flutter/lib/src/rendering/object.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Mar 20, 2026
@chunhtai chunhtai added the CICD Run CI/CD label Mar 20, 2026
}
}
if (!built) {
semanticsNodes.clear();

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.

No logic changes here right? These two lines are moved into _produceSemanticsNode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

since _produceSemanticsNode is responsible for populate the cache, it should also be the one to do the pre clean up

// Create an inner node to hold the configuration and children, and the cachedSemanticsNode will
// hold the inner node and the sibling nodes so that all of them can be merged together.
final innerNode = SemanticsNode(showOnScreen: renderObject.showOnScreen);
renderObject.assembleSemanticsNode(innerNode, configProvider.effective, children);

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.

In this case, should the innerNode set isMergingSemanticsOfDescendants to false since node is now the one that's supposed to be doing the merging, or it doesn't matter since everything in the subtree will now be merged into node's SemanticsData eventually?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I doesn't matter as you said

final controller = TextEditingController(text: '123');
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(

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.

Sorry for the delay, looks like you'll have to update the test?

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 27, 2026
@chunhtai chunhtai added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Apr 27, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 27, 2026
@auto-submit

auto-submit Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/183745, because - The status or check suite Linux web_canvaskit_tests_1 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 27, 2026
@chunhtai chunhtai added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Apr 27, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 27, 2026
@auto-submit

auto-submit Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/183745, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 28, 2026
@chunhtai chunhtai added the CICD Run CI/CD label Apr 28, 2026
@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 29, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 29, 2026
Merged via the queue into flutter:master with commit b8ed448 Apr 29, 2026
87 of 88 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 29, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 1, 2026
Roll Flutter from 81bc3d69535f to 707dbc0420a3 (85 revisions)

flutter/flutter@81bc3d6...707dbc0

2026-05-01 Rusino@users.noreply.github.com Removing TODOs from the WebParagraph code and addressing technical debts. (flutter/flutter#185168)
2026-05-01 mbrase@google.com Ensure that vulkan_interface.h gets included before vk_mem_alloc.h (flutter/flutter#185777)
2026-05-01 nshahan@google.com [flutter_tools] Bump dwds dependency to v27.1.1 (flutter/flutter#185357)
2026-05-01 engine-flutter-autoroll@skia.org Roll Dart SDK from 6d4a319cbdac to 9aa7097f2e3e (3 revisions) (flutter/flutter#185888)
2026-05-01 engine-flutter-autoroll@skia.org Roll Skia from fa1dcb289709 to 7ac6d42f2fd0 (1 revision) (flutter/flutter#185887)
2026-05-01 engine-flutter-autoroll@skia.org Roll Skia from 54cc00adde38 to fa1dcb289709 (3 revisions) (flutter/flutter#185880)
2026-05-01 chris@bracken.jp [iOS] Migrate to FlutterFMLTaskRunner(s) (flutter/flutter#185815)
2026-05-01 ad13dtu@gmail.com Remove material imports from navigator_on_did_remove_page_test and scrollable_in_overlay_test (flutter/flutter#182546)
2026-05-01 engine-flutter-autoroll@skia.org Roll Skia from 2e279266f06a to 54cc00adde38 (3 revisions) (flutter/flutter#185872)
2026-05-01 srawlins@google.com dev: Remove unused parameters (flutter/flutter#185345)
2026-05-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from HN5VYzftnf_B8T-n9... to VnzuUefDQR0UhQ1L1... (flutter/flutter#185870)
2026-05-01 robert.ancell@canonical.com Use g_free when using glib memory allocation (flutter/flutter#185519)
2026-05-01 engine-flutter-autoroll@skia.org Roll Dart SDK from d30df3428f2e to 6d4a319cbdac (2 revisions) (flutter/flutter#185862)
2026-05-01 73785960+xfce0@users.noreply.github.com Remove trivial test utility cross-imports from material and cupertino… (flutter/flutter#184295)
2026-05-01 129008657+DaveT1991@users.noreply.github.com Inline test callback painter in tab scaffold test (flutter/flutter#184851)
2026-05-01 jhy03261997@gmail.com [a11y] Add support for high contrast themes in the a11y assessments app  (flutter/flutter#185801)
2026-05-01 jhy03261997@gmail.com [a11y assessment app] Use default color for banner (flutter/flutter#185804)
2026-04-30 73091075+MohamedRisaldarTA@users.noreply.github.com Added name to AUTHORS (flutter/flutter#185586)
2026-04-30 sanaullah.383@hotmail.com Remove semantics_tester import from raw_material_button_test.dart (flutter/flutter#184806)
2026-04-30 sanaullah.383@hotmail.com Remove semantics_tester import from user_accounts_drawer_header_test.dart (flutter/flutter#184809)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 7b88c5c281e5 to 2e279266f06a (5 revisions) (flutter/flutter#185854)
2026-04-30 evanwall@buffalo.edu Handle symmetric rectangular and elliptical round super ellipses in the uber SDF renderer  (flutter/flutter#185695)
2026-04-30 15619084+vashworth@users.noreply.github.com Match on process name before killing for SwiftPM (flutter/flutter#185774)
2026-04-30 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#185838)
2026-04-30 engine-flutter-autoroll@skia.org Roll Dart SDK from 25910e31a6d2 to d30df3428f2e (5 revisions) (flutter/flutter#185839)
2026-04-30 brackenavaron@gmail.com Check cross imports test subfolders (flutter/flutter#185493)
2026-04-30 112751483+shivanshu877@users.noreply.github.com test: inline TestCallbackPainter in cupertino/picker_test.dart (flutter/flutter#185398)
2026-04-30 97480502+b-luk@users.noreply.github.com Update customer testing version (flutter/flutter#185830)
2026-04-30 jason-simmons@users.noreply.github.com Adapt the Metal shader library output list for debug versus release mode (flutter/flutter#185798)
2026-04-30 jason-simmons@users.noreply.github.com [Impeller] Port a recent Vulkan swapchain fence waiting fix to the AHB version of the swapchain (flutter/flutter#185763)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 26a59aa71eff to 7b88c5c281e5 (1 revision) (flutter/flutter#185821)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 6b4167b4e204 to 26a59aa71eff (4 revisions) (flutter/flutter#185808)
2026-04-30 jhy03261997@gmail.com [a11y] Mark SemanticsNode dirty when customSemanticsActions change  (flutter/flutter#185707)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 1bd2f1cc2746 to 6b4167b4e204 (8 revisions) (flutter/flutter#185799)
2026-04-30 chris@bracken.jp [iOS] Extract FlutterVSyncClient from vsync_waiter_ios (flutter/flutter#185737)
2026-04-30 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nnv8-SSam6yE8dw4z... to HN5VYzftnf_B8T-n9... (flutter/flutter#185782)
2026-04-29 chris@bracken.jp [iOS] Soften TaskRunner.postTask(delay:task:) delay check (flutter/flutter#185729)
2026-04-29 koji.wakamiya@gmail.com Add reportErrors to ImageStreamListener (flutter/flutter#180327)
2026-04-29 engine-flutter-autoroll@skia.org Roll Skia from f5c781c083c7 to 1bd2f1cc2746 (5 revisions) (flutter/flutter#185761)
2026-04-29 47866232+chunhtai@users.noreply.github.com Update merge semantics logic to merge sibling nodes (flutter/flutter#183745)
2026-04-29 engine-flutter-autoroll@skia.org Roll Packages from ba80f8f to cde5b36 (12 revisions) (flutter/flutter#185748)
2026-04-29 srawlins@google.com examples: Remove unused parameters (flutter/flutter#185346)
2026-04-29 nate.w5687@gmail.com Update TickerMode.getValuesNotifier to handle initialization during State.dispose (flutter/flutter#185248)
2026-04-29 katelovett@google.com Update triage links (flutter/flutter#185714)
2026-04-29 42399845+xxxOVALxxx@users.noreply.github.com Add support for high contrast and color inversion on Android (flutter/flutter#182263)
2026-04-29 engine-flutter-autoroll@skia.org Roll Skia from 05251260fda6 to f5c781c083c7 (2 revisions) (flutter/flutter#185743)
...
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11630)

Roll Flutter from 81bc3d69535f to 707dbc0420a3 (85 revisions)

flutter/flutter@81bc3d6...707dbc0

2026-05-01 Rusino@users.noreply.github.com Removing TODOs from the WebParagraph code and addressing technical debts. (flutter/flutter#185168)
2026-05-01 mbrase@google.com Ensure that vulkan_interface.h gets included before vk_mem_alloc.h (flutter/flutter#185777)
2026-05-01 nshahan@google.com [flutter_tools] Bump dwds dependency to v27.1.1 (flutter/flutter#185357)
2026-05-01 engine-flutter-autoroll@skia.org Roll Dart SDK from 6d4a319cbdac to 9aa7097f2e3e (3 revisions) (flutter/flutter#185888)
2026-05-01 engine-flutter-autoroll@skia.org Roll Skia from fa1dcb289709 to 7ac6d42f2fd0 (1 revision) (flutter/flutter#185887)
2026-05-01 engine-flutter-autoroll@skia.org Roll Skia from 54cc00adde38 to fa1dcb289709 (3 revisions) (flutter/flutter#185880)
2026-05-01 chris@bracken.jp [iOS] Migrate to FlutterFMLTaskRunner(s) (flutter/flutter#185815)
2026-05-01 ad13dtu@gmail.com Remove material imports from navigator_on_did_remove_page_test and scrollable_in_overlay_test (flutter/flutter#182546)
2026-05-01 engine-flutter-autoroll@skia.org Roll Skia from 2e279266f06a to 54cc00adde38 (3 revisions) (flutter/flutter#185872)
2026-05-01 srawlins@google.com dev: Remove unused parameters (flutter/flutter#185345)
2026-05-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from HN5VYzftnf_B8T-n9... to VnzuUefDQR0UhQ1L1... (flutter/flutter#185870)
2026-05-01 robert.ancell@canonical.com Use g_free when using glib memory allocation (flutter/flutter#185519)
2026-05-01 engine-flutter-autoroll@skia.org Roll Dart SDK from d30df3428f2e to 6d4a319cbdac (2 revisions) (flutter/flutter#185862)
2026-05-01 73785960+xfce0@users.noreply.github.com Remove trivial test utility cross-imports from material and cupertino… (flutter/flutter#184295)
2026-05-01 129008657+DaveT1991@users.noreply.github.com Inline test callback painter in tab scaffold test (flutter/flutter#184851)
2026-05-01 jhy03261997@gmail.com [a11y] Add support for high contrast themes in the a11y assessments app  (flutter/flutter#185801)
2026-05-01 jhy03261997@gmail.com [a11y assessment app] Use default color for banner (flutter/flutter#185804)
2026-04-30 73091075+MohamedRisaldarTA@users.noreply.github.com Added name to AUTHORS (flutter/flutter#185586)
2026-04-30 sanaullah.383@hotmail.com Remove semantics_tester import from raw_material_button_test.dart (flutter/flutter#184806)
2026-04-30 sanaullah.383@hotmail.com Remove semantics_tester import from user_accounts_drawer_header_test.dart (flutter/flutter#184809)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 7b88c5c281e5 to 2e279266f06a (5 revisions) (flutter/flutter#185854)
2026-04-30 evanwall@buffalo.edu Handle symmetric rectangular and elliptical round super ellipses in the uber SDF renderer  (flutter/flutter#185695)
2026-04-30 15619084+vashworth@users.noreply.github.com Match on process name before killing for SwiftPM (flutter/flutter#185774)
2026-04-30 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#185838)
2026-04-30 engine-flutter-autoroll@skia.org Roll Dart SDK from 25910e31a6d2 to d30df3428f2e (5 revisions) (flutter/flutter#185839)
2026-04-30 brackenavaron@gmail.com Check cross imports test subfolders (flutter/flutter#185493)
2026-04-30 112751483+shivanshu877@users.noreply.github.com test: inline TestCallbackPainter in cupertino/picker_test.dart (flutter/flutter#185398)
2026-04-30 97480502+b-luk@users.noreply.github.com Update customer testing version (flutter/flutter#185830)
2026-04-30 jason-simmons@users.noreply.github.com Adapt the Metal shader library output list for debug versus release mode (flutter/flutter#185798)
2026-04-30 jason-simmons@users.noreply.github.com [Impeller] Port a recent Vulkan swapchain fence waiting fix to the AHB version of the swapchain (flutter/flutter#185763)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 26a59aa71eff to 7b88c5c281e5 (1 revision) (flutter/flutter#185821)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 6b4167b4e204 to 26a59aa71eff (4 revisions) (flutter/flutter#185808)
2026-04-30 jhy03261997@gmail.com [a11y] Mark SemanticsNode dirty when customSemanticsActions change  (flutter/flutter#185707)
2026-04-30 engine-flutter-autoroll@skia.org Roll Skia from 1bd2f1cc2746 to 6b4167b4e204 (8 revisions) (flutter/flutter#185799)
2026-04-30 chris@bracken.jp [iOS] Extract FlutterVSyncClient from vsync_waiter_ios (flutter/flutter#185737)
2026-04-30 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nnv8-SSam6yE8dw4z... to HN5VYzftnf_B8T-n9... (flutter/flutter#185782)
2026-04-29 chris@bracken.jp [iOS] Soften TaskRunner.postTask(delay:task:) delay check (flutter/flutter#185729)
2026-04-29 koji.wakamiya@gmail.com Add reportErrors to ImageStreamListener (flutter/flutter#180327)
2026-04-29 engine-flutter-autoroll@skia.org Roll Skia from f5c781c083c7 to 1bd2f1cc2746 (5 revisions) (flutter/flutter#185761)
2026-04-29 47866232+chunhtai@users.noreply.github.com Update merge semantics logic to merge sibling nodes (flutter/flutter#183745)
2026-04-29 engine-flutter-autoroll@skia.org Roll Packages from ba80f8f to cde5b36 (12 revisions) (flutter/flutter#185748)
2026-04-29 srawlins@google.com examples: Remove unused parameters (flutter/flutter#185346)
2026-04-29 nate.w5687@gmail.com Update TickerMode.getValuesNotifier to handle initialization during State.dispose (flutter/flutter#185248)
2026-04-29 katelovett@google.com Update triage links (flutter/flutter#185714)
2026-04-29 42399845+xxxOVALxxx@users.noreply.github.com Add support for high contrast and color inversion on Android (flutter/flutter#182263)
2026-04-29 engine-flutter-autoroll@skia.org Roll Skia from 05251260fda6 to f5c781c083c7 (2 revisions) (flutter/flutter#185743)
...
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.

InputDecorator prefix and suffix text isn't included in semantics when TextField is wrapped in MergeSemantics.

2 participants