Fixing a crash when minimizing a window with custom viewport. (#16704)
Objective
Fix a crash when minimizing a window. (#16704) It happens when the window contains Camera with a custom Viewport.
Solution
Remove ExtractedCamera when the corresponding camera in main world has zero target size. It indicates that the window is minimized.
Testing
Tested in Windows 11. Previously the split_screen example crashes when the window is minimized; and with this change, it would not crash. Other behaviors remain unchanged.
Welcome, new contributor!
Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨
Bump. It should be a minor modification.
Bump
Do the removed components get re-added when the window is maximized again?
Do the removed components get re-added when the window is maximized again?
Yes. When the window is not minimized, the components are extracted to render world in every render loop.
Do these fixes need to be added to this function extract_ui_camera_view ? I used these codes on this function and it fixed my problem. Thanks a lot!
Sounds reasonable then :) My only worry is that this list of "bad components" could silently grow one day when someone creates a new component and doesn't add it here, which would reintroduce the bug. But fixing it like this for now is better than leaving it broken!
In my opinion, it is not a problem, because these components have been removing in the same function before this fix. (Please refer to line 1134 in crates/bevy_render/src/camera/camera.rs) Therefore whoever creates a new component should be aware of the removal, no matter with or without the fix.
Do these fixes need to be added to this function extract_ui_camera_view ? I used these codes on this function and it fixed my problem. Thanks a lot!
Adding the fix to one of the functions should be enough, because putting it into different functions essentially do the same thing, only changing the schedule where the operation is done.
could the list of components to remove be shared with the one line 1134? Either checking both condition at the same time, or with a function removing them, or a type alias?
could the list of components to remove be shared with the one line 1134? Either checking both condition at the same time, or with a function removing them, or a type alias?
Thanks for your advice. I have merged them into a single type ExtractedCameraComponents, so that they can be changed with a single modification
I am not familiar with the workflow, so is there anything to be done to get ready for final review?
@RuelYasa someone with triage rights needs to properly tag it, that's it. Unfortunately, it looks like this PR has merge conflicts now :/ Could you fix them and then ping me so I can tag it again? :)
@janhohenheim The conflicts have been fixed, thanks for your help.