bevyengine / bevyengine/bevy

`Window.set_resolution()` and `set_present_mode()` don't have expected side-effects

Open
#5,111 1 comment 0 reactions 0 assignees View on GitHub
C-Bug O-Windows
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

main at a138804d618a00d9e42a62547603a0b094be1042

## \[Optional\] Relevant system information

Windows 10 21H2

## What you did

https://github.com/bevyengine/bevy/pull/4865 adds a simple example for testing whether Bevy is keeping a consistent frame pace and an accurate time step. That example uses several methods on a `bevy::window::Window` struct so you can test the effects of various presentation options without needing to compile and restart:

- `set_present_mode`
- `set_mode`
- `set_resolution` (for restoring the window to a default size when switching back to windowed mode)

## What went wrong

`set_mode` switches the window between windowed, borderless, and fullscreen modes depending on its argument. This is the behavior I expected for the other two methods.

But `set_present_mode` and `set_resolution` have no visible effect, at least not on Windows 10 (which is currently the easiest platform for me to test on). The window size after switching back to windowed mode is always the same as the fullscreen resolution, and the present mode stays locked to Fifo. (For the latter, it's easy to tell because the example in #4865 also includes frame time diagnostics; if you switch the starting present mode to Mailbox or Immediate and recompile, the average frame times are somewhere down in the 2-3ms neighborhood on this computer, as opposed to the 16.6ms neighborhood you get with Fifo on a 60hz monitor.)

You can tell from the log messages that the methods _are_ properly changing the values stored in the primary Window struct; it's just that queuing those other `WindowCommand`s doesn't seem to get anything done.

I haven't yet been able to check whether these methods work on other platforms or not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.