winit icon indicating copy to clipboard operation
winit copied to clipboard

iOS. High CPU usage when application does nothing.

Open VladasZ opened this issue 7 months ago • 7 comments

Description

I noticed that my iPhone gets really hot when I run my projects. While trying to debug this issue I stripped all my code and only winit code remained but the phone was still hot.

I see that Xcode shows constant CPU load: image

The same project has 0 CPU load on Android: image On Windows: image On Linux: image And on macOS: image

What may cause the issue?

Minimal example to reproduce:

Rust code:

#[no_mangle]
pub extern "C" fn start_test_game() -> std::ffi::c_int {
    use winit::{
        application::ApplicationHandler,
        event::WindowEvent,
        event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
        window::WindowId,
    };

    struct App;

    impl ApplicationHandler for App {
        fn resumed(&mut self, event_loop: &ActiveEventLoop) {}
        fn window_event(&mut self, event_loop: &ActiveEventLoop, id: WindowId, event: WindowEvent) {}
    }

    let event_loop = EventLoop::new().unwrap();

    event_loop.set_control_flow(ControlFlow::Wait);

    event_loop.run_app(&mut App).unwrap();
    0
}

main.m in Xcode project:

int start_test_game(void);

int main(int argc, char * argv[]) {
    return start_test_game();
}

Device and iOS version

iPhone 13 Pro running iOS 17.5.1, iPhone 5s running iOS 12.5.7, iPhone 15 Simulator running iOS 17.4

Winit version

0.30.1

VladasZ avatar Jul 23 '24 20:07 VladasZ