Skip to content

[Metal] Avoid NSWindow for hidden offscreen windows#565

Open
taylorhoward92 wants to merge 2 commits intoOGRECave:masterfrom
taylorhoward92:fix/hidden-metal-no-nswindow-master
Open

[Metal] Avoid NSWindow for hidden offscreen windows#565
taylorhoward92 wants to merge 2 commits intoOGRECave:masterfrom
taylorhoward92:fix/hidden-metal-no-nswindow-master

Conversation

@taylorhoward92
Copy link
Copy Markdown

Summary

When mHidden is true and no external window handle is provided, the Metal backend creates an NSWindow anyway (just without calling [window orderFront:]). Since NSWindow must be created and manipulated on the main thread on macOS, this makes it unsafe to create hidden/offscreen rendering windows from background threads — a common pattern for headless server-side rendering.

Changes

When mHidden is true and no external handle is provided, create a standalone OgreMetalView without wrapping it in an NSWindow. This mirrors the spirit of VulkanWindowNull in the Vulkan backend, which similarly avoids platform window creation for headless rendering.

The externalWindowHandle / NSView / NSWindow resolution path is wrapped in if( !mMetalView ) so it is only executed when a view was not already created by the hidden-window path.

When mHidden is true and no external window handle is provided,
create a standalone OgreMetalView without wrapping it in an
NSWindow.

NSWindow must be created and manipulated on the main thread on
macOS; skipping it makes hidden (offscreen) windows safe to create
from any thread.  This mirrors the spirit of VulkanWindowNull in
the Vulkan backend, which similarly avoids platform window creation
for headless rendering.

Signed-off-by: Taylor Howard <taylor.howard@absiko.com.au>
@taylorhoward92 taylorhoward92 marked this pull request as ready for review April 7, 2026 11:06
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant