rust-windowing / rust-windowing/winit

Very long RedrawRequested emission on WASM application

Open
#4,429 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

B - bug DS - web
Dominant language
Rust
Stars
6.2k
Forks
1.3k
Avg merge
2d 19h
Merged PRs (30d)
9

Description

Description

I'm using new version 0.31.0-beta.2
I did not try with another version.

I use wgpu in Fifo present mode.

Each frame I display:

  • RedrawRequested delta: the time between two RedrawRequested receptions.
  • game logic elapsed: the time to handle all my code between two RedrawRequested receptions.

RedrawRequested emission is quite regular, but very long on WASM, 60 FPS unreachable.
Maybe I'm wrong but I suppose the browser is throttling the application even though the tab is focused and I'm using it.
I couldn't investigate more.
Is that a winit bug ?

Native:

Event loop setup:

    let event_loop = EventLoop::new().unwrap();
    event_loop.set_control_flow(ControlFlow::Poll);
    event_loop.run_app(Game::empty()).unwrap();
DEBUG game: RedrawRequested delta: 16ms894µs968ns
DEBUG game: game logic elapsed: 4ms695µs704ns
...

Web - Firefox:

Event loop setup:

    let event_loop = EventLoop::new().unwrap();
    event_loop.set_control_flow(ControlFlow::Poll);
    event_loop.set_poll_strategy(PollStrategy::Scheduler); //already by default
    event_loop.run_app(Game::empty()).unwrap();
DEBUG game: RedrawRequested delta: 82ms
DEBUG game: game logic elapsed: 5ms
...
Tested browsers

Firefox

Tested devices

Laptop ubuntu 22

Winit version

0.31.0-beta.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report names no repository files or tests. Start by reproducing the provided EventLoop setup with ControlFlow::Poll and PollStrategy::Scheduler in a Firefox WASM build, then compare RedrawRequested timing with the native output. Done means determining whether the delay is browser throttling or winit behavior and identifying the relevant fix or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.