Skip to content

MonitorHandle and VideoMode can become invalid leading to panics #3258

@daxpedda

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 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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    S - apiDesign and usability

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions