rust-windowing / rust-windowing/winit
Application panics when reading `Window::inner_size` after X server has terminated (e.g.: on user log-out)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 1.3k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 9
Description
Description
Our application's error reporting has been capturing a lot of called Result::unwrap() on an Err value: Connection(IoError(Custom { kind: Other, error: UnknownError })) panics, stemming from the unwrap in Window::inner_size_physical.
We finally have figured out the cause:
- User logs out of their desktop environment, shutting down the X server or Xwayland.
- Application is still running; some logic calls
Window::inner_size. winitattempts to get the window geometry, and receives a connection error, as the display server is gone.winitpanics
Xlib traditionally would end up invoking exit() here as part of the default I/O (fatal) error handler. winit's use of xcb makes it responsible, instead, for handling connection errors.
My basic request here is that winit doesn't panic in this situation and instead handles it in any more graceful way (could mean calling exit() like Xlib would have). This is an expected situation, and should be handled accordingly.
I think that in an ideal world (but curious what winit devs think), Window::inner_size returns a Result, allowing it to tell the caller that the size couldn't be computed, and winit then terminates the event loop at its earliest convenience, allowing for graceful application shutdown.
OS and window mananger
Arch Linux; Gnome (either X11 or Wayland w/ application running via Xwayland).
Winit version
0.30.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/platform_impl/linux/x11/window.rs at Window::inner_size_physical, especially the unwrap around the geometry lookup described in the issue. Trace how Window::inner_size is exposed and how connection errors are handled elsewhere. Done means an X server termination no longer causes this call to panic and the resulting shutdown or error behavior is defined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, rust
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100