moonbit-community / moonbit-community/window
Need cheap monitor enumeration or lazy video modes for Bevy-style monitor sync
Nobody has claimed this yet.
- Dominant language
- MoonBit
- Stars
- 2
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Moon Game Studio mirrors Bevy bevy_winit::system::create_monitors, which can call monitor enumeration from the event-loop sync path to keep monitor entities in sync.
With Milky2018/window@0.5.1 on macOS, available_monitors() constructs each MonitorHandle through monitor_from_display_id(), and that eagerly calls available_display_video_modes(display_id). In an mgstudio 2D example capture, sampling the process repeatedly shows the hot path:
winit_create_monitors_system
-> @windowing.available_monitors()
-> monitor_from_display_id
-> available_display_video_modes
-> SLDisplayCopyAllDisplayModes
This keeps the example runtime at ~100% CPU and blocks Bevy-equivalent screenshot gates. Mgstudio can avoid re-inserting its ECS Monitor component for unchanged monitor handles, but it cannot avoid the lower-level eager video-mode enumeration without diverging from Bevy/winit monitor-sync semantics.
Needed API/behavior:
available_monitors()should be cheap enough to call from a Bevy-style monitor sync path.MonitorHandleconstruction should not enumerate all video modes unlessvideo_modes()is actually requested, or the package should expose a separate cheap monitor enumeration API with native id, name, position, size, scale factor, and current mode only.MonitorHandleequality / identity should rely on native monitor identity and not force full video-mode enumeration.
Verification expectation:
- Running a Bevy-style monitor sync loop for a windowed mgstudio example should no longer spend frame time in
SLDisplayCopyAllDisplayModeswhen monitor topology is unchanged. - A 90-frame 2D example capture should not be CPU-bound by monitor video-mode enumeration.
Relevant local dependency code inspected in Milky2018/window@0.5.1:
macos/monitor.mbt::available_monitors()
macos/monitor.mbt::monitor_from_display_id()
macos/monitor.mbt::available_display_video_modes()
Contributor guide
No contributing guide indexed for this repository
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 with macos/monitor.mbt, especially available_monitors(), monitor_from_display_id(), and available_display_video_modes(). Trace how monitor identity and video_modes() are used, then verify the chosen behavior with a Bevy-style monitor sync loop and a 90-frame 2D example capture; done means unchanged topology no longer spends frame time in SLDisplayCopyAllDisplayModes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos
- Domain
- operating-systems, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100