Skip to content

Fix macOS HUD and dynamic-overlay-resize on Metal present thread - #88

Open
actuallyitsnathaniel wants to merge 2 commits into
ThatGuyMcd:mainfrom
actuallyitsnathaniel:fix/mac-hud-resize-reflow
Open

actuallyitsnathaniel wants to merge 2 commits into
ThatGuyMcd:mainfrom
actuallyitsnathaniel:fix/mac-hud-resize-reflow

Conversation

@actuallyitsnathaniel

Copy link
Copy Markdown
Contributor

What

  • On macOS, RT64's present thread was reading a stale Cocoa window size from plume (getWindowAttributes returned a cache and only scheduled async refresh). Metal swapchain / ImGui targets could stick after drag-resize or fullscreen. New registered plume patch always reads live attributes.
  • HUD Fit-to-window gutters only republished viewport extent while the ImGui overlay (or other UI) was drawing. With the menu closed, Expand world + Fit HUD could disagree after resize. ui::draw now calls set_viewport_extent every present, before the overlay-closed early return.

Pattern checklist

  • First-party changes are in-place edits under runtime-recomp/, modding/ or scripts/ (no new patches/<name>/)
  • Third-party changes are *.patch files registered in patches/manifest.json (patches/plume/0004-live-cocoa-window-attributes.patch)
  • Guest hooks only via guest-hooks/hooks.toml; symbols only via symbols/*.toml (n/a)
  • New settings, launcher pages and owned services are registered, and their contract docs are updated (n/a)
  • netplay/legacy_identity.hpp updated (reviewed by both owners) if simulation, wire or owned-service behaviour changed (n/a)
  • Tests added or updated; python3 scripts/check.py --suite guard passes locally (present-thread Metal overlay resize check; HUD extent publish-before-early-return pipeline guard)
  • Platforms considered: rebuilt and ran on macOS (build/dkr-runtime-macos). Host preset (RT64 off) 141/141. Windows / Linux / iOS / Android not rebuilt for this PR.

Risk

Low. Plume change is Apple window-size reads only; HUD change only republishes Fit viewport aspect when size changes. Capsule base_sha256 for runtime_ui.cpp updated. Revert the commit to roll back.

@swhitt swhitt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime_ui.cpp is in DRIFTED_BASES on main now, so the base_sha256 bump fails the pinned-bytes check after a merge - just drop the manifest change.

The HUD extent move looks good.

+ // / resize off the main thread; a cached size plus async refresh leaves
+ // the drawable and ImGui target stuck until something else refreshes.
+ NSWindow *nsWindow = (__bridge NSWindow *)windowHandle;
+ NSRect contentFrame = [[nsWindow contentView] frame];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-[NSView frame] and backingScaleFactor are main-thread-only, which is why upstream caches here and refreshes on the main queue. Reading them from the present thread races live resize and Main Thread Checker will flag it. The UIKit half has the same problem, and iOS wasn't rebuilt.

Maybe refresh the cache synchronously on the main thread from the SDL resize event instead (updateWindowAttributesInternal(true)), and keep the present thread reading the cache?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants