Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with phantom ui node children #14490

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

eidloi
Copy link

@eidloi eidloi commented Jul 26, 2024

Objective

The ui_layout_system relies on change detection to sync parent-child relation to taffy. The children need to by synced before node removal to avoid trying to set deleted nodes as children (due to how the different queries collect entities). This however may leave nodes that were removed set as children to other nodes in special cases.

Fixes #11385

Solution

The solution is simply to re-sync the changed children after the nodes are removed.

Testing

Tested with sickle_ui where docking zone highlights would end up glitched when docking was done in a certain manner:

  • run the docking_zone_splits example
  • pop out a tab from the top
  • dock the floating panel in the center right
  • grab another tab and try to hover the original static docking zone: the highlight is semi-stuck
  • (NOTE: sometimes it worked even without the fix due to scheduling order not producing the bugged query results)

After the fix, the issue is no longer present.

NOTE: The performance impact should be minimal, as the child sync relies on change detection. The change detection was also the reason the parent nodes remained "stuck" with the phantom children if no other update were done to them.

@alice-i-cecile alice-i-cecile added this to the 0.14.1 milestone Jul 26, 2024
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 26, 2024
@eidloi
Copy link
Author

eidloi commented Jul 27, 2024

Please don't merge yet, I noticed that there was an optimization update for the children update that I should be using. I also realized that it might be better to use Changed<Children> filter for the query if we are iterating over it twice.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 27, 2024
@eidloi
Copy link
Author

eidloi commented Jul 27, 2024

I have replaced the loop with the iter as in the first update. Discord tells me changing the query wouldn't help 🤷
@mockersf I think github should discard approvals when a commit is force pushed like I did just now (I amended my commit)

@alice-i-cecile alice-i-cecile added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jul 27, 2024
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 29, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jul 29, 2024
Merged via the queue into bevyengine:main with commit 396153a Jul 30, 2024
28 checks passed
mockersf pushed a commit that referenced this pull request Aug 2, 2024
# Objective

The `ui_layout_system` relies on change detection to sync parent-child
relation to taffy. The children need to by synced before node removal to
avoid trying to set deleted nodes as children (due to how the different
queries collect entities). This however may leave nodes that were
removed set as children to other nodes in special cases.

Fixes #11385

## Solution

The solution is simply to re-sync the changed children after the nodes
are removed.

## Testing

Tested with `sickle_ui` where docking zone highlights would end up
glitched when docking was done in a certain manner:
- run the `docking_zone_splits` example
- pop out a tab from the top
- dock the floating panel in the center right
- grab another tab and try to hover the original static docking zone:
the highlight is semi-stuck
- (NOTE: sometimes it worked even without the fix due to scheduling
order not producing the bugged query results)

After the fix, the issue is no longer present.

NOTE: The performance impact should be minimal, as the child sync relies
on change detection. The change detection was also the reason the parent
nodes remained "stuck" with the phantom children if no other update were
done to them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI Node's Style changes are ignored for unparented nodes as long as the parent exists
3 participants