Skip to content

Conversation

@cBournhonesque
Copy link
Contributor

Objective

I've been having panics in situations where:

  • I despawn a UI Root Node in PostUpdate
  • I don't have any system order dependency between my PostUpdate system and UiSystems::Prepare, so there was no sync point between the two

Therefore the order of operations was:

  • My system runs and queues a command to despawn a root node
  • The UI system runs and tries to insert Propagate on my root node
  • CommandExecutions:
    • my command to despawn the root node is executed
    • the command to insert Propagate is executed, causing a panics

This means that any attempt to despawn a Root node in PostUpdate will probably cause these kinds of panics.

Solution

Replace the command with try_insert so that if the Root Node is despawned we don't try to add a Propagate component on it.

Testing

This fixed the issue in my repo

@cBournhonesque cBournhonesque added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets D-Trivial Nice and easy! A great choice to get started with Bevy S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 12, 2025
Copy link
Contributor

@villor villor left a comment

Choose a reason for hiding this comment

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

Makes sense! The system shouldn't cause panics when root entities are removed in the same schedule.

@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 Oct 12, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17.3 milestone Oct 12, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 12, 2025
Merged via the queue into bevyengine:main with commit d5595c9 Oct 12, 2025
47 checks passed
mate-h pushed a commit to mate-h/bevy that referenced this pull request Oct 22, 2025
# Objective

I've been having panics in situations where:
- I despawn a UI Root Node in PostUpdate
- I don't have any system order dependency between my PostUpdate system
and `UiSystems::Prepare`, so there was no sync point between the two

Therefore the order of operations was:
- My system runs and queues a command to despawn a root node
- The UI system runs and tries to insert `Propagate` on my root node
- CommandExecutions:
  - my command to despawn the root node is executed
  - the command to insert Propagate is executed, causing a panics

This means that any attempt to despawn a Root node in PostUpdate will
probably cause these kinds of panics.

## Solution

Replace the command with `try_insert` so that if the Root Node is
despawned we don't try to add a Propagate component on it.

## Testing

This fixed the issue in my repo
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 D-Trivial Nice and easy! A great choice to get started with Bevy 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.

3 participants