Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Jul 12, 2024

OverlayPortal attaches its overlaychild's renderobject to overlay directly while keeps its semantics tree under overlayportal.

This become a problem when the overlaychild markNeedsSemanticsUpdate that it propagate upward the rendering tree.

This means instead of marking dirty upward to the OverlayPortal, it directly mark Overlay dirty instead and skip OverlayPortal.

Currently this does not pose an issue other than unnecessary rebuilds, but it become a problem when I try to optimize the semantics tree compilation #150394.

After the optimization it won't rebuild semantics node unless it is marked dirty. Since the OverlayPortal widget does not get marked dirty, it won't update the subtree.

Pre-launch Checklist

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

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 12, 2024
}

node = node.parent!;
node = node.semanticsParent!;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this line is the only reason that RenderObject.semanticsParent is needed. Is it possible to change the implementation of markNeedsSemanticsUpdate to a recursive one so we can override _RenderDeferredLayoutBox.markNeedsSemanticsUpdate to propagate the call to its surrogate parent? So that we don't have to change the interface of RenderObject.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cant think of a clean way to do this with the mayProduceSiblingNodes. The requirement is the following:

If a node will produce sibling nodes, it must mark two semantics boundaries above to be dirty

If we were to do this, we have to add additional flag either on renderobject or additional parameter to the markNeedsSemanticsUpdate([int howManyBoundaries]).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The semanticsparent is also used for some look up in _getSemanticsForParent.

Copy link
Contributor

Choose a reason for hiding this comment

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

The semanticsparent is also used for some look up in _getSemanticsForParent.

The call from _getSemanticsForParent only wants to check if the parent is null it seems (so it doesn't matter for OverlayPortal).

If a node will produce sibling nodes, it must mark two semantics boundaries above to be dirty

Ah ok that makes sense. (But at the same time that feels a bit weird, not familiar with semantics tree, but why is the closest semantics boundary invalidated if this has child configurations, but it's fine if parent has child configurations?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the parent is not markNeedsSemanticsUpdate, it won't change its sibling node that get pass on two level up.

If the parent it self is markNeedsSemanticsUpdate it is not the current node's job to mark two level above the parent dirty. It will be when the parent's markNeedsSemanticsUpdate call to mark two level above.

@chunhtai chunhtai requested a review from LongCatIsLooong July 23, 2024 22:19
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the explanation! Also maybe add @visibleForaoberriding to semanticsParent?

@chunhtai chunhtai force-pushed the overlay-semantics branch from 967d5da to 2ecffb4 Compare July 23, 2024 23:44
@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 23, 2024
@auto-submit auto-submit bot merged commit 7912e6d into flutter:master Jul 24, 2024
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
…#151688)

OverlayPortal attaches its overlaychild's renderobject to overlay directly while keeps its semantics tree under overlayportal.

This become a problem when the `overlaychild` markNeedsSemanticsUpdate that it propagate upward the rendering tree.

This means instead of marking dirty upward to the OverlayPortal, it directly mark Overlay dirty instead and skip `OverlayPortal`.

Currently this does not pose an issue other than unnecessary rebuilds, but it become a problem when I try to optimize the semantics tree compilation flutter#150394.

After the optimization it won't rebuild semantics node unless it is marked dirty. Since the OverlayPortal widget does not get marked dirty, it won't update the subtree.
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…#151688)

OverlayPortal attaches its overlaychild's renderobject to overlay directly while keeps its semantics tree under overlayportal.

This become a problem when the `overlaychild` markNeedsSemanticsUpdate that it propagate upward the rendering tree.

This means instead of marking dirty upward to the OverlayPortal, it directly mark Overlay dirty instead and skip `OverlayPortal`.

Currently this does not pose an issue other than unnecessary rebuilds, but it become a problem when I try to optimize the semantics tree compilation flutter#150394.

After the optimization it won't rebuild semantics node unless it is marked dirty. Since the OverlayPortal widget does not get marked dirty, it won't update the subtree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants