rust-windowing / rust-windowing/winit

Improve documentation and/or API to help avoid garbage data

Open
#1,809 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

(I know this issue has been brought up a few times before, so I apologize for the near duplicate. I feel that there is more to discuss though.)

I see in #1536 and a few other issues that because winit doesn't draw anything to the window, showing garbage data before first render isn't considered a bug. This is also mentioned in the documentation here:

Note that many platforms will display garbage data in the window's client area if the application doesn't render anything to the window by the time the desktop compositor is ready to display the window to the user. If you notice this happening, you should create the window with visible set to false and explicitly make the window visible only once you're ready to render into it.

Given that this workaround is required in order to use winit correctly on such platforms (including Windows), I think this documentation could use more details or an example about how to do this.

For example, where is visible supposed to be set back to true? It can't be after a redraw or resize event, since those events aren't triggered if the window isn't visible. If it's done on the first run of the event callback, then garbage data is still displayed until the first render (noticeable when the render or resize events take a significant amount of time).

This issue is present in the wgpu examples as well as bevy, which both use winit. I think ideally winit should "just work" here, i.e. as long as you handle the redraw event, garbage data won't be displayed. But I realize this might not be technically feasible, so winit should at least provide an easy and well-documented way to do this.

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

Start with the linked winit documentation section on drawing on the window, then compare its visibility guidance with the wgpu examples and bevy usage mentioned in the issue. Determine whether the result should be clearer documentation or an API change, and consider the first-render, redraw, and resize timing described. Done means a decided, reliable way to avoid garbage data is documented or supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.