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 panic on Text UI without Cameras #11405

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

doonv
Copy link
Contributor

@doonv doonv commented Jan 18, 2024

Objective

Fix #11396.

Solution

Don't panic on taffy node not existing.

Plus minor warning text improvement.

Copy link
Contributor

@pablo-lua pablo-lua left a comment

Choose a reason for hiding this comment

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

Simple changes that will probably fix the bug.

If we go about improving warnings, there are some points that I suggest a change (Maybe in a future PR):

            None => {
                if cameras.is_empty() {
                    warn!("No camera found to render UI to. To fix this, add at least one camera to the scene.");
                } else {
                    warn!(
                        "Multiple cameras found, causing UI target ambiguity. \
                        To fix this, add an explicit `TargetCamera` component to the root UI node {:?}",
                        entity
                    );
                }
                continue;
            }

In this part, we warn the user about the existence of "multiple" cameras, but this warn isn't exactly true. In fact, this function return None only if there is no cameras pointing to the PrimaryWindow. If there is no Cameras pointing to the PrimaryWindow and cameras isn't empty, the warn message isn't exactly accurate.
One possible messages is: "No camera found for PrimaryWindow, but found Cameras for other windows"

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets labels Jan 18, 2024
@alice-i-cecile alice-i-cecile added this to the 0.13 milestone Jan 18, 2024
@alice-i-cecile alice-i-cecile added the C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide label Jan 18, 2024
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

&mut self,
entity: Entity,
measure_func: taffy::node::MeasureFunc,
) -> Option<()> {
Copy link
Member

Choose a reason for hiding this comment

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

This should return a Result, not an Option.

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'll do that in a future PR.

@@ -305,7 +310,7 @@ pub fn ui_layout_system(
Some(camera_entity) => {
let Ok((_, camera)) = cameras.get(camera_entity) else {
warn!(
Copy link
Member

Choose a reason for hiding this comment

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

We should debounce this warning using the macro from #10808 so we don't spam the users :)

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 did consider that but ended up not doing that because different entities could trigger that warning, but it will only trigger for the first entity.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, let's leave it as is for now I suppose.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Feel free to clean it up further (like a result type), but I won't block on that. Fixing the crash is more important.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jan 18, 2024
@doonv
Copy link
Contributor Author

doonv commented Jan 18, 2024

Why is this marked as a breaking change?

@matiqo15
Copy link
Member

Why is this marked as a breaking change?

update_measure was renamed to try_update_measure

@doonv
Copy link
Contributor Author

doonv commented Jan 18, 2024

Why is this marked as a breaking change?

update_measure was renamed to try_update_measure

It's in a private module.

@alice-i-cecile
Copy link
Member

Why is this marked as a breaking change?

update_measure was renamed to try_update_measure

It's in a private module.

We should remove its pub marking then to avoid further confusion.

@alice-i-cecile alice-i-cecile removed the C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide label Jan 18, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 18, 2024
Merged via the queue into bevyengine:main with commit 03ee959 Jan 18, 2024
27 checks passed
@doonv doonv mentioned this pull request Jan 19, 2024
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.

Panic on ui without Cameras
4 participants