Skip to content

MonitorHandle and VideoMode can become invalid leading to panics #3258

Open

Description

@daxpedda

This is an issue in MonitorHandle and VideoMode. In #3303 (comment) @madsmtm has pointed out that on MacOS these handles are not connected to EventLoop in any way, so they should be fine. We should try and cover all backends and make sure handle method can't and can live after the event loop is exited or otherwise come up with an alternative, e.g. adding a lifetime.

Cc #971, #3102 and #2646.


Original Windows only issue

The MonitorHandle on Windows holds a HMONITOR, which can become invalid if e.g. the monitor is disconnected. Or to be more precise, the Windows documentation recommends to listen to WM_DISPLAYCHANGE, which can potentially invalidate any HMONITOR.

All of the MonitorHandle methods call the GetMonitorInfo function and just unwrap(), which would cause a panic if a HMONITOR has become invalid.

See #3255, which only fixed MonitorHandle::video_modes().

Activity

  1. added
    DS - win32
    on Dec 6, 2023
  2. kchibisov commented on Dec 6, 2023

    @kchibisov
    Member

    This is true for literally any backend. The same with other resources. It's kind of known problem and we generally. have a bunch of PRs around to not panic in monitor handle.

  3. added
    S - api
    and removed
    DS - win32
    on Dec 6, 2023
  4. changed the title [-]Windows: `MonitorHandle` can become invalid leading to panics[/-] [+]`MonitorHandle` and `VideoMode` can become invalid leading to panics[/+] on Dec 26, 2023
  5. added this to the Version 0.30.0 milestone on Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    S - api

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions