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

Window size isn't correct until second frame when scale factor is overridden #17188

Open
rparrett opened this issue Jan 6, 2025 · 0 comments · May be fixed by #17208
Open

Window size isn't correct until second frame when scale factor is overridden #17188

rparrett opened this issue Jan 6, 2025 · 0 comments · May be fixed by #17208
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@rparrett
Copy link
Contributor

rparrett commented Jan 6, 2025

Bevy version

main

Relevant system information

SystemInfo { os: "macOS 14.5 Sonoma", kernel: "23.5.0", cpu: "Apple M1 Max", core_count: "10", memory: "64.0 GiB" }
AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }

High DPI display (scale factor 2)

What you did

use bevy::{diagnostic::FrameCount, prelude::*, window::WindowResolution};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
                ..default()
            }),
            ..default()
        }))
        .add_systems(Startup, startup)
        .add_systems(Update, print_windows)
        .run();
}

fn startup(windows: Query<&Window>, frame_count: Res<FrameCount>) {
    for window in &windows {
        info!("{} {:?} (startup)", frame_count.0, window.resolution);
    }
}

fn print_windows(windows: Query<&Window>, frame_count: Res<FrameCount>) {
    for window in &windows {
        info!("{} {:?} (update)", frame_count.0, window.resolution);
    }
}

What went wrong

The WindowResolution is incorrect during Startup and for one run of the Update schedule, and then becomes correct on the next frame.

2025-01-06T12:55:54.906932Z  INFO bevy_winit::system: Creating new window App (0v1)
2025-01-06T12:55:54.932602Z  INFO sfo: Frame 0: WindowResolution { physical_width: 3840, physical_height: 2160, scale_factor_override: Some(1.0), scale_factor: 2.0 } (startup)
2025-01-06T12:55:54.941606Z  INFO sfo: Frame 0: WindowResolution { physical_width: 3840, physical_height: 2160, scale_factor_override: Some(1.0), scale_factor: 2.0 } (update)
2025-01-06T12:55:55.002012Z  INFO sfo: Frame 1: WindowResolution { physical_width: 1920, physical_height: 1080, scale_factor_override: Some(1.0), scale_factor: 2.0 } (update)

Additional information

Related to #17183

@rparrett rparrett added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 6, 2025
@BenjaminBrienen BenjaminBrienen added A-Windowing Platform-agnostic interface layer to run your app in S-Needs-Investigation This issue requires detective work to figure out what's going wrong D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Triage This issue needs to be labelled labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants