beyond-all-reason / beyond-all-reason/RecoilEngine

SDL_WINDOWEVENT_LEAVE unreliable on macOS surfaceless EGL + CAMetalLayer setup

Open
#2,992 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
679
Forks
290
Avg merge
3d 2h
Merged PRs (30d)
40

Description

On the macOS Apple Silicon path (surfaceless EGL + CAMetalLayer present, introduced in #2991), \`SDL_WINDOWEVENT_LEAVE\` events do not appear to fire reliably. This causes BAR's \`gfx_limit_idle_fps\` widget to engage the VSync clamp during active play, dropping FPS to ~15.

**Repro:** run BAR on Apple Silicon with the workaround in beyond-all-reason/Beyond-All-Reason#7813 disabled (remove the \`Platform.osFamily == "MacOS"\` short-circuit at the top of \`gfx_limit_idle_fps:Update()\`). With mouse inside the window during active play, FPS should stay at 30+ but clamps to ~15 after a few seconds, as if the engine thought the mouse had left.

**Workaround (in place):** the BAR widget short-circuits its \`Update()\` on \`Platform.osFamily == "MacOS"\`. See beyond-all-reason/Beyond-All-Reason#7813 commit history for \`gfx_limit_idle_fps\`.

**Proper fix (engine-side):** investigate why SDL \`WINDOWEVENT_LEAVE\` doesn't fire on the surfaceless EGL + CAMetalLayer window. Likely candidates:
- SDL2 surfaceless window may not be a "real" SDL_Window for event purposes; mouse-leave detection may need to come from CAMetalLayer's tracking area instead.
- A synthetic mouse-leave event could be emitted from the Metal event-handling path.

Filed as a follow-up to #2991 so the Mac-side widget workaround can eventually be removed.

Contributor guide

Open the contributing guide

Research direction

Reproduce the BAR Apple Silicon case with the gfx_limit_idle_fps MacOS short-circuit disabled, then trace SDL_WINDOWEVENT_LEAVE through the surfaceless EGL + CAMetalLayer and Metal event-handling paths. Determine whether leave detection belongs to the SDL window or CAMetalLayer tracking, and verify that active play no longer triggers the VSync clamp so the widget workaround can be removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.