Repository navigation
Conversation
Co-authored-by: multica-agent <github@multica.ai>
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.
Why
On macOS,
runalways makes the process an app: it createsNSApplication, a window, and anMTKViewwhose layer AppKit backs. A program that only draws into render targets and reads them back, such as a Quick Look extension's renderer or a tool that saves frames, doesn't need any of that, and pays for it:com.apple.LaunchServices.databaseto every process watching it. The Quick Look thumbnail agent, for one, cancels the requests it has in flight when that notification arrives, so a thumbnail drawn this way never arrives.A layer-backed
NSViewalone is enough to startNSApplication:-[MTKView initWithFrame:device:]creates its layer, and+[NSViewBackingLayer defaultValueForKey:]calls+[NSApplication sharedApplication].Change
Platform::macos_headless,falseby default. When it's set,runhands over torun_headless, which creates noNSApplication, no window and noNSView:NSObjectsubclass that answers what the Metal backend asks of anMTKView(device,colorPixelFormat,depthStencilPixelFormat,sampleCount,bounds,drawableSize,setDrawableSize:,currentDrawable,currentRenderPassDescriptoranddraw) from aCAMetalLayernothing shows. Its render pass descriptor is built asMTKViewbuilds its own, with a multisampled color texture resolving into the drawable and a depth/stencil texture, both kept until the drawable's size changes.perform_redrawuntil the app quits, inside an autorelease pool each time round, as nothing drains one otherwise.It only draws with Metal:
run_headlessasserts it. The display setuprunandrun_headlessshare moves intonew_display. With the default, the code path is the same as before. Other platforms ignore the field.Verification
On macOS 27, in a macroquad game (CHOMP) that draws its frames into render targets and reads them back:
NSApplicationis created (a breakpoint on+[NSApplication sharedApplication]is never hit), no window exists for the process, and over repeated launches of the app bundle's executable,com.apple.LaunchServices.databaseis never posted, where each launch posted it before.cargo buildhas no new warnings.rustfmt --checkflags nothing in the added lines, only formatting that's already on master.