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

Make InputFocus optional in bevy_winit #17358

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

IceSentry
Copy link
Contributor

Objective

  • Stop bevy from crashing when losing window focus

Solution

  • The InputFocus resource is optional but is accessed unconditionally in bevy_winit. Make it optional.

Testing

  • Ran the window_settings example

Note

It's possible this might not be a full fix for the issue, but this stop bevy from crashing.

Closes #16961
Closes #17227

@IceSentry IceSentry added P-Crash A sudden unexpected crash A-Windowing Platform-agnostic interface layer to run your app in A-Input Player input via keyboard, mouse, gamepad, and more labels Jan 14, 2025
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.

This is a fine fix (defensive programming and all that), but I feel like we should be initializing the InputFocus resource when a11y is enabled too, in case it hasn't been otherwise added. The old equivalent was added here; they just got unified because they were exactly the same type.

@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Jan 14, 2025
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Jan 14, 2025
Copy link
Contributor

@ChristopherBiscardi ChristopherBiscardi left a comment

Choose a reason for hiding this comment

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

I haven't seen any crashes after dozens of runs with this PR. (crashes are happening on main without this PR).

@BenjaminBrienen BenjaminBrienen added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 14, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 14, 2025
Merged via the queue into bevyengine:main with commit 41fd280 Jan 14, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more A-Windowing Platform-agnostic interface layer to run your app in D-Straightforward Simple bug fixes and API improvements, docs, test and examples P-Crash A sudden unexpected crash 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.

window_settings example crashes on startup mixed lighting example breaks with Res<InputFocus>
4 participants