[Metal] Avoid NSWindow for hidden offscreen windows#565
Open
taylorhoward92 wants to merge 2 commits intoOGRECave:masterfrom
Open
[Metal] Avoid NSWindow for hidden offscreen windows#565taylorhoward92 wants to merge 2 commits intoOGRECave:masterfrom
taylorhoward92 wants to merge 2 commits intoOGRECave:masterfrom
Conversation
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>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
mHiddenis true and no external window handle is provided, the Metal backend creates anNSWindowanyway (just without calling[window orderFront:]). SinceNSWindowmust 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
mHiddenis true and no external handle is provided, create a standaloneOgreMetalViewwithout wrapping it in anNSWindow. This mirrors the spirit ofVulkanWindowNullin the Vulkan backend, which similarly avoids platform window creation for headless rendering.The
externalWindowHandle/NSView/NSWindowresolution path is wrapped inif( !mMetalView )so it is only executed when a view was not already created by the hidden-window path.