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

Enable power saving mode back in the editor on Linux #567

Closed
mrDIMAS opened this issue Nov 15, 2023 · 2 comments · Fixed by #568
Closed

Enable power saving mode back in the editor on Linux #567

mrDIMAS opened this issue Nov 15, 2023 · 2 comments · Fixed by #568

Comments

@mrDIMAS
Copy link
Member

mrDIMAS commented Nov 15, 2023

Power-saving mode is disabled on Linux for now because of a subtle bug in winit which cannot handle control flow juggling properly on Wayland causing the editor to crash. This is mostly a tracking issue.

@IceGuye
Copy link
Contributor

IceGuye commented Nov 15, 2023

There may be a way to create a minimal working example in pure winit in order to report this bug to winit team, but until now, I am not able to reproduce this bug in pure winit. So I put the codes here. If anyone can make a minimal example and reproduce the bug, please report to winit's github.

use winit::{
    event_loop::{EventLoop, ControlFlow},
    window::WindowBuilder,
};

fn main() {
    let event_loop = EventLoop::new().unwrap();

    let window = WindowBuilder::new()
        .build(&event_loop)
        .unwrap();

    event_loop.run(move |event, elwt| {
        elwt.set_control_flow(ControlFlow::Wait);
    })
    .unwrap();
}

@mrDIMAS
Copy link
Member Author

mrDIMAS commented Nov 16, 2023

I guess we (you 😅 ) should also try

use winit::{
    event::Event,
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};

fn main() {
    let event_loop = EventLoop::new().unwrap();

    let window = WindowBuilder::new().build(&event_loop).unwrap();

    let mut counter = 300;
    event_loop
        .run(move |event, elwt| {
            if let Event::AboutToWait = event {
                if counter > 0 {
                    window.request_redraw();
                    counter -= 1;
                }
            }

            if counter > 0 {
                elwt.set_control_flow(ControlFlow::Poll);
            } else {
                elwt.set_control_flow(ControlFlow::Wait);
            }
        })
        .unwrap();
}

This is the closest code to what the editor does on startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants