macOS snapshot 调研
macOS snapshot: can glaze grow Snapshot() ([]byte, error) with purego only?
Research note for the runvm screenshot/print fork. Answers whether
github.com/progrium/glaze@v0.0.0-20261029191355-bc7899dbb235 can gain a
Snapshot() on its macOS backend that returns PNG bytes, using only purego
(no cgo), and how much of it is already proven by code shipping in that module.
Verdict up front: likely-works. The exact mechanism needed — a Go closure
handed to WebKit as an Objective-C block, invoked asynchronously from the
completion handler while glaze’s Run() pumps — is already in that file and
already exercised on macos-latest by glaze’s own tests (Find, see §3).
What is left is a selector chain of object/BOOL returns (NSImage →
NSBitmapImageRep → NSData) that needs no new ABI, plus a plumbing problem
one layer above glaze (§7).
1. How glaze talks to Objective-C
glaze is a hand-written AppKit/WebKit binding over github.com/ebitengine/purego
and purego/objc. The runtime libraries are loaded once in ensureInit
(Cocoa and WebKit are dlopened globally so WebKit’s Objective-C classes
register into the process):
webview_darwin.go:151ensureInit()→webview_darwin.go:152-157purego.Dlopen("/System/Library/Frameworks/Cocoa.framework/Cocoa", …)and.../WebKit.framework/WebKit,RTLD_GLOBAL|RTLD_LAZY.webview_darwin.go:163-171resolves_dispatch_main_qviapurego.Dlsym(RTLD_DEFAULT, …)and bindsdispatch_async_fwithpurego.RegisterLibFunc.
There is a small helper layer, at the top of webview_darwin.go:
| helper | line | what it does |
|---|---|---|
selCache sync.Map |
webview_darwin.go:81 |
caches selectors because objc.RegisterName takes the global objc lock |
sel(name) objc.SEL |
webview_darwin.go:83 |
objc.RegisterName + cache |
class(name) objc.ID |
webview_darwin.go:93 |
objc.GetClass, panics when the class is missing |
nsstr(s) objc.ID |
webview_darwin.go:101 |
[NSString stringWithUTF8String:] |
cstr(id) string |
webview_darwin.go:106 |
unsafe.Slice over -UTF8String’s char * |
autorelease(f func()) |
webview_darwin.go:122 |
wraps f in an NSAutoreleasePool and drains it |
responds(id, sel) |
webview_darwin.go:1124 |
-respondsToSelector: for availability checks |
Everything goes through objc.ID.Send / objc.Send[T]
(purego/objc/objc_runtime_darwin.go:141 and :161), which are wrappers over
objc_msgSend. glaze itself never calls objc_msgSend directly; the one raw
SyscallN is to reuse WebKit’s own IMP for willOpenMenu:withEvent::
webview_darwin.go:398-405:purego.Dlopen("/usr/lib/libobjc.A.dylib"),purego.RegisterLibFunc(&methodImplementation, lib, "class_getMethodImplementation"), thenpurego.SyscallN(wkWillOpenMenu, self, _cmd, menu, event)atwebview_darwin.go:409-410.
Struct returns go through objc.Send[T], e.g.
objc.Send[cgRect](w.window, sel("frame")) at webview_darwin.go:1362; on
amd64 Send[T] automatically picks objc_msgSend_stret when T is a struct
larger than 16 bytes (purego/objc/objc_runtime_darwin.go:164-172), on arm64 it
is always objc_msgSend. cgRect is defined at webview_darwin.go:74.
2. Does glaze already construct Objective-C classes or blocks?
Classes: yes, by the dozen. registerClasses() (webview_darwin.go:185)
uses objc.RegisterClass, which is objc_allocateClassPair +
class_addMethod + objc_registerClassPair
(purego/objc/objc_runtime_darwin.go:277; declared at :41-52, bound with
purego.RegisterLibFunc at :107-110). Registered classes include:
GlazeAppDelegate(webview_darwin.go:187)GlazeScriptMessageHandler, conforming toWKScriptMessageHandler(webview_darwin.go:220)GlazePaintHandler(webview_darwin.go:236),GlazePaintCover(:254)GlazeWindowDelegate(:264)GlazeUIDelegate(:280), conforming toWKUIDelegate, carryingwebView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:(:285), the media-capture permission method (:290), the three script-dialog methods (:301,:308,:315) andcreateWebViewWithConfiguration:…(:329)GlazeURLSchemeHandler, conforming toWKURLSchemeHandler(webview_darwin.go:349-356, methodsstartURLSchemeTask/stopURLSchemeTaskat:430and:475)GlazeFirstMouseWebView/GlazeWebView, WKWebView subclasses (:370,:379)
So the callback direction ObjC → Go is implemented the other way round from
blocks: glaze registers a class whose methods are Go closures, conforms it to a
protocol, and hands the object to WebKit as a delegate. The Go closure receives
(self, _cmd, …) and recovers the *webview from a global registry
(registerInstance / lookupEngine, webview_darwin.go:536-551) rather than
from an ivar.
Blocks: yes — two different things are already done with them.
- Calling blocks that ObjC handed us.
invokeNativeBlock(webview_darwin.go:508-519) drives a foreign block throughNSInvocationwith a hand-written type string ("v@?@","v@?q","v@?B"), becauseobjc.Block.Invokeonly knows blocks made byobjc.NewBlock. Used at:297,:304,:311,:323,:502,:1997,:2108,:2119. - Passing our own Go block to ObjC.
Finddoes exactly what a snapshot needs — see §3.
3. If blocks are already used: the pattern
webview_darwin.go:1425-1443 is the template, and it is a WebKit completion
handler, i.e. the same shape as takeSnapshotWithConfiguration::
func (w *webview) Find(text string, backwards bool, done func(bool)) {
performOnMain(func() {
…
autorelease(func() {
cfg := class("WKFindConfiguration").Send(sel("new"))
cfg.Send(sel("autorelease"))
cfg.Send(sel("setBackwards:"), backwards)
// WebKit copies the block; this reference is released below.
block := objc.NewBlock(func(_ objc.Block, result objc.ID) {
callFind(done, objc.Send[bool](result, sel("matchFound")))
})
w.webView.Send(sel("findString:withConfiguration:completionHandler:"), nsstr(text), cfg, block)
block.Release()
})
})
}
Four rules are encoded there, and they all transfer to a snapshot block:
- Build it on the UI thread, inside
autorelease(the block’s Go closure may touch AppKit, and the returned autoreleased objects —WKFindConfigurationhere — must be drained by a pool you own). - The Go closure’s first parameter must be
objc.Block—purego’sblockCache.encodepanics otherwise (purego/objc/objc_block_darwin.go:130-132); the remaining parameters are the block’s real arguments, and the return type must match@encode. block.Release()right after the send, because the callee copies it.- Do not block waiting for the completion —
doneis a callback, not a channel receive; see §5.
The test file proves the same path end-to-end offline:
webview_darwin_test.go:107-124 (openPanelCompletionScenario) makes a
objc.NewBlock, passes it to invokeOpenPanelCompletion, and asserts the Go
closure runs. And find_test.go:17-56 runs the real WebKit completion handler
under w.Run() on the macOS CI runner.
What objc.NewBlock actually builds
This is purego v0.11.1 (glaze/go.mod pins github.com/ebitengine/purego
v0.11.1), purego/objc/objc_block_darwin.go:
blockLayout(:51-58) — the literal:isa Class,flags uint32, 4 bytes padding,invoke uintptr,descriptor *blockDescriptor= 32 bytes.blockDescriptor(:37-44) —reserved,size,reserved(the copy helper slot, left nil),dispose,signature *uint8= 40 bytes.- flags (
:24-30):blockHasCopyDispose = 1<<25andblockHasSignature = 1<<30→0x42000000. (The host task’s guess of0x40000000is only the signature bit;puregoalso sets copy/dispose.) - isa is
__NSMallocBlock__(:22,:195), not_NSConcreteStackBlock. invokeis onepurego.NewCallbackper Go function type, cached inblockCache.layouts(:169-184), so repeated snapshots do not burn callback slots (purego/syscall_unix.go:44caps them at 2000).descriptor.size = unsafe.Sizeof(blockLayout{})(:192),disposeis apurego.NewCallback(cache.Functions.Delete)(:201) so the Go closure is dropped from the map when the refcount hits zero.NewBlock(:239-246) lays the literal out in Go memory, then calls_Block_copy(Block.Copy,:213-215, bound atobjc_runtime_darwin.go:125). Because the flags lackBLOCK_NEEDS_FREE(1<<24) andBLOCK_IS_GLOBAL(1<<28), libclosure treats it as a stack block:malloc+memmove+ refcount 1, into a real heap block. So no manual_NSConcreteStackBlock, no manualBlock_copy, no manual struct literal is needed —objc.NewBlockis already the block-literal ABI, done.
Lifetime: the returned objc.Block is a +1 reference; Release() drops it. The
callee (WebKit) Block_copys it if it stores it, which is the documented
convention for completion handlers and is what glaze’s Find relies on in
production code. The captured Go state lives in blockFunctionCache, not in the
block’s memory, so it stays valid across the copy and is freed by the dispose
helper.
4. The full call sequence for PNG bytes
Objects/selectors needed (all macOS 10.12+, no availability guard needed for the
snapshot itself; guard afterScreenUpdates which is 10.15+):
| step | class | selector | returns |
|---|---|---|---|
| 1 | WKSnapshotConfiguration |
+new then -autorelease (glaze pattern, webview_darwin.go:1432-1433) |
config |
| 2 | WKSnapshotConfiguration |
-setSnapshotWidth: with [NSNumber numberWithDouble:] |
— |
| 3 | WKSnapshotConfiguration |
-setAfterScreenUpdates: (10.15+, responds guard) |
— |
| 4 | WKWebView (w.webView, set at webview_darwin.go:1009) |
-takeSnapshotWithConfiguration:completionHandler: |
— (async) |
| 5 | block | (NSImage *image, NSError *error) |
— |
| 6 | NSImage |
-TIFFRepresentation |
NSData * |
| 7 | NSBitmapImageRep |
+imageRepWithData: |
NSBitmapImageRep * |
| 8 | NSBitmapImageRep |
-representationUsingType:properties: with NSBitmapImageFileTypePNG = 4, nil properties |
NSData * |
| 9 | NSData |
-length (NSUInteger) and -bytes (const void *) |
bytes → Go |
Notes and traps:
- Configuration may be nil, but do not rely on it. Apple’s header does not
mark
snapshotConfigurationnullable; pass a real[[WKSnapshotConfiguration alloc] init]autoreleased. Cost is one message. - Sizing. With
snapshotWidthunset the image is the view’s size in points, so a 2× Retina capture is not what you get. SettingsnapshotWidth = @(viewWidthInPoints)gives a deterministic pixel width and a proportional height. This matters forrunvm: Linux captures the whole X root at the Xvfb size, Windows captures the client rect; macOS should be told explicitly what width to produce rather than inheriting whatever the window is. rect(-setRect:, aCGRect) is optional. If you set it you are passing a 32-byte struct by value throughobjc_msgSend— glaze already does this (webview_darwin.go:1008passescgRecttoinitWithFrame:configuration:), so it works, but there is no reason to use it for a full-page capture because the default is the whole view.- No
objc_msgSend_stretcase. Everything returned here isid,BOOLorNSUInteger— register returns on both arm64 and amd64.NSSize/CGRectare only needed if you ask for-bounds/-frame;objc.Send[cgRect]already handles the amd64 stret path if you do (objc_runtime_darwin.go:161-173). - Reading
NSDatainto Go is the sameunsafe.Slicetrick ascstr(webview_darwin.go:106-118), but with an explicit length. Copy immediately: the data is owned by an autoreleased object. - Alternatives, and why not.
-printOperationWithPrintInfo:is synchronous but givesNSPrintOperation→ PDF, not PNG, and printing a WKWebView runs the print panel machinery;-createPDFWithConfiguration:completionHandler:(macOS 11+) is the same block problem but yields PDF, whichrunvmwould then have to rasterize. Neither is simpler than the ~40 lines above, and the PNG route feedsinternal/h5/pdf.go’s existing raster path unchanged.
5. Threading
w.webViewmust be messaged on the UI thread; glaze’s convention isperformOnMain(webview_darwin.go:594-606), which runs inline when already on the main thread and otherwisedispatch_async_fes to_dispatch_main_qand waits.- WebKit delivers
takeSnapshot’s completion handler on the main thread. glaze’sRun()calls[NSApp run](webview_darwin.go:1186-1219), which drains the main dispatch queue as part of the run loop, so the block fires whileRun()is pumping. Nodispatch_asyncto main is needed, andFindis the in-tree proof:find_test.gochains four searches from inside the completion handler, underw.Run(), on macOS CI. - The one real deadlock trap is a blocking
Snapshot()called from the UI thread: the thread that must run the completion handler would be parked on a channel. Two ways out, and glaze already contains both patterns:- expose the callback form (
func([]byte, error)), likeFind; - or, for a blocking
Snapshot()on the UI thread, pump a nested loop exactly likepumpUntilClosed(webview_darwin.go:1221-1240) until the result arrives. Caveat, documented in that same function: a pump that is itself nested inside a main-queue callout will not drain the main queue again until the callout returns, so if WebKit hops the completion through the main queue the pump will never see it.
- expose the callback form (
- From a background goroutine (the
runvmhost’s command loop is one —internal/h5/host.go:112-133reads stdin on a goroutine while the main goroutine sits inf.Run()), the blocking shape is safe:performOnMainreturns after the send, then the caller waits on a channel while the main loop keeps pumping.
6. Risks / unknowns
Cannot be verified without a real Mac:
- Does
takeSnapshotreturn a non-blankNSImagefor a window glaze never put on screen?Options.Hidden(webview_darwin.go:799) builds the window but keeps it out of the way;runvmnever asks for a hidden page capture (Session.Screenshotrequiresvisible,internal/h5/session.go:309-311), so this is mostly a non-issue — but it means the macOS path inherits the same “page must be visible” precondition, just not the Xvfb-style “must own the display” one. - Snapshot timing vs. paint.
runvmalready does tworequestAnimationFrames plus a 120 ms beat before capturing (internal/h5/session.go:320-324).afterScreenUpdates:YESis the WebKit-native equivalent; whether it is enough (or too slow) on CI is empirical. - Whether WebKit copies the completion block for this API.
Findproves it forfindString:withConfiguration:completionHandler:; the block-copy convention is uniform across WebKit’s completion-handler APIs, but a missingBlock_copyin one API would show up as a use-after-free on the macOS runner, not locally. - Intel Macs.
macos-latestis arm64; glaze’s darwin amd64 code path (including theobjc_msgSend_stretbranch) is never exercised by CI. The snapshot itself uses no struct returns, so this is a low risk, but it is untested. - Image scale/orientation. WebKit’s snapshot may be sized in points; whether the resulting PNG matches what Linux/Windows produce for the same viewport is a comparison nobody can do from Linux.
- Sandbox/TCC. A plain
NSImage→ PNG conversion needs no screen-recording permission (unlikeCGWindowListCreateImage/screencapture), which is precisely the argument for this route over a window-server capture. Worth confirming under a sandboxed.appifrunvmever ships one.
What a macos-latest CI test would actually prove:
- the block literal round-trip (Go closure ← WebKit completion) for this selector, including retain/release, i.e. the only genuinely novel ABI;
- that the completion is delivered while
Run()pumps; - that the
NSImage→NSBitmapImageRep→ PNG chain produces a decodable PNG with non-zero dimensions; - that the bytes actually contain ink (a pixel check), which is the only real answer to unknown #1 for a visible window.
It would not prove anything about Intel, about a sandboxed app, or about a hidden/off-screen window.
7. Plumbing (one layer above glaze) — do not skip this
Even a perfect glaze.Snapshot() does not make runvm’s h5_screenshot work on
macOS, because of how the current capture is wired:
Session.Screenshot(internal/h5/session.go:308-325) runs in the MCP server process, not in the page host. It callscaptureSupported+capturePNG(internal/h5/screen_linux.go:30) which shells out toxwdagainst the display the child draws on, orPrintWindowagainst the child’s HWND (internal/h5/capture_windows.go:22). Both are cross-process OS captures.- On macOS the pixels only exist inside the child’s
WKWebView. There is no cross-process equivalent that would not need screen-recording permission, so the capture must move into the host process: a newhostCmdop (e.g."snapshot",internal/h5/protocol.go:12-16) whose reply carries the PNG base64 inhostMsg.Result(:20-31), handled inhost.go’s command loop, andSession.Screenshotgrows a “ask the host” branch for darwin. - Between glaze and
runvmsitswebframe, whoseFramekeeps the webview unexported (webframe.go:91-93,w glaze.WebView). So aglaze.Snapshot()is unreachable fromrunvmuntilwebframeexposes it:func (f *Frame) Snapshot() ([]byte, error)(or a pass-through returning theglaze.WebView). That is a third module to fork/bump, andrunvm’sgo.modalready carries thereplacefor glaze (runvm/go.mod:19), so the fork story exists but now spans two forks. -
Do not add
Snapshot()toglaze.WebView(webview_common.go:37). The Linux and Windows backends implement that interface (webview_linux.go,webview_windows.go), so a new method there breaks their build and glaze’s own CI matrix. Use a side interface and a type assertion:// Snapshotter is implemented by backends that can capture the page as PNG. type Snapshotter interface{ Snapshot() ([]byte, error) }webframecan then doif s, ok := f.w.(glaze.Snapshotter); ok { … }without any change to the existing interface.
Concrete Go sketch (not compiled)
For webview_darwin.go in the fork. Uses only helpers that already exist in
that file: sel, class, autorelease, performOnMain, responds, and
objc.NewBlock.
// nsBitmapImageFileTypePNG is NSBitmapImageFileTypePNG from AppKit.
const nsBitmapImageFileTypePNG = 4
// Snapshotter is implemented by backends that can capture the page as PNG.
// It is deliberately NOT part of WebView: the Linux and Windows backends do not
// implement it, and adding it to that interface would break their builds.
type Snapshotter interface{ Snapshot() ([]byte, error) }
// Snapshot captures the page as PNG.
//
// Call it from a goroutine other than the UI thread: WebKit delivers the
// completion handler on the main queue, so a Snapshot that parked the UI thread
// would wait for a callback that thread alone can run. The internal
// snapshotAsync form exists for UI-thread callers (see Find).
func (w *webview) Snapshot() ([]byte, error) {
type result struct {
png []byte
err error
}
ch := make(chan result, 1)
w.snapshotAsync(func(png []byte, err error) { ch <- result{png, err} })
r := <-ch
return r.png, r.err
}
// snapshotAsync starts a WKWebView snapshot and reports the PNG on the UI
// thread (the thread WebKit calls the completion handler on).
func (w *webview) snapshotAsync(done func([]byte, error)) {
performOnMain(func() {
if w.webView == 0 {
done(nil, errors.New("webview: snapshot: no web view"))
return
}
autorelease(func() {
// A real configuration, not nil: the header does not mark the
// parameter nullable. new + autorelease matches WKFindConfiguration
// in Find.
cfg := class("WKSnapshotConfiguration").Send(sel("new"))
cfg.Send(sel("autorelease"))
// Pin the output width instead of inheriting the view's point size,
// so a Retina window and a 1x window produce comparable PNGs.
if b := objc.Send[cgRect](w.webView, sel("bounds")); b.Size.Width > 0 {
width := class("NSNumber").Send(sel("numberWithDouble:"), b.Size.Width)
cfg.Send(sel("setSnapshotWidth:"), width)
}
// macOS 10.15+: make WebKit flush the current frame first.
if responds(cfg, "setAfterScreenUpdates:") {
cfg.Send(sel("setAfterScreenUpdates:"), true)
}
// WebKit copies the block; our reference is released below. The
// closure runs on the main thread, inside the run loop that Run()
// owns, so it may touch AppKit directly.
block := objc.NewBlock(func(_ objc.Block, image, nserr objc.ID) {
if image == 0 {
done(nil, fmt.Errorf("webview: snapshot: %s", nsErrorText(nserr)))
return
}
png, err := pngFromNSImage(image)
done(png, err)
})
w.webView.Send(sel("takeSnapshotWithConfiguration:completionHandler:"), cfg, block)
block.Release()
})
})
}
// pngFromNSImage converts a WKWebView snapshot (an NSImage) to PNG bytes via
// TIFF, the only lossless bridge NSImage offers to NSBitmapImageRep.
func pngFromNSImage(image objc.ID) ([]byte, error) {
tiff := image.Send(sel("TIFFRepresentation"))
if tiff == 0 {
return nil, errors.New("webview: snapshot: NSImage has no TIFF representation")
}
rep := class("NSBitmapImageRep").Send(sel("imageRepWithData:"), tiff)
if rep == 0 {
return nil, errors.New("webview: snapshot: NSBitmapImageRep could not decode the image")
}
// Second argument is NSDictionary<NSBitmapImageRepPropertyKey,id> * and may
// be nil: no compression hints, just the PNG default.
data := rep.Send(sel("representationUsingType:properties:"), nsBitmapImageFileTypePNG, objc.ID(0))
if data == 0 {
return nil, errors.New("webview: snapshot: PNG encoding failed")
}
// NSUInteger fits objc.ID on both 64-bit architectures.
n := int(data.Send(sel("length")))
if n <= 0 {
return nil, errors.New("webview: snapshot: empty PNG data")
}
ptr := data.Send(sel("bytes")) // const void *
out := make([]byte, n)
copy(out, unsafe.Slice((*byte)(unsafe.Pointer(ptr)), n)) // #nosec G103 -- copying NSData's buffer before the pool drains
return out, nil
}
// nsErrorText renders an NSError for a message, without failing on nil.
func nsErrorText(err objc.ID) string {
if err == 0 {
return "no image and no error"
}
desc := err.Send(sel("localizedDescription"))
if desc == 0 {
return "no image"
}
return cstr(desc.Send(sel("UTF8String")))
}
If the UI thread must be able to call it, replace the blocking Snapshot with
the callback form (mirroring Find) or wait with a nested pump like
pumpUntilClosed (webview_darwin.go:1221-1240), remembering the caveat in §5.
How to verify on CI (ordered)
- Compile-only check, locally, no Mac:
GOOS=darwin GOARCH=arm64 go build ./... && GOOS=darwin GOARCH=amd64 go build ./...plusGOOS=darwin go vet ./.... Catches every typo in the selector chain except the ones that only the ObjC runtime can catch. - Add a scenario, not a test. In the fork, add
snapshotScenario() stringtowebview_darwin_test.goand register it inTestMain(webview_darwin_test.go:38-92) next toresFind, so it runs on the main goroutine afterruntime.LockOSThread(). Model it onfindScenario(find_test.go:17-56): create aNewWithOptionswith aSchemeHandlerspage,OnNavigation→ callSnapshot()from a new goroutine (or usesnapshotAsync), thenw.Terminate(). - Assert three things, not one:
bytes.HasPrefix(png, []byte("\x89PNG\r\n\x1a\n"));image/png.Decodesucceeds andBounds()is non-zero; and the decoded image has ink (sum of a sampled grid of RGB values > 0). A blank-but-valid PNG is the failure mode this whole note is worried about. - Cap the scenario with a
time.AfterFunc(15*time.Second, …)watchdog that callsTerminate, exactly asfindScenariodoes (find_test.go:49), so a never-delivered completion fails the run instead of hanging the job. - Push a branch. glaze’s
macosjob (.github/workflows/ci.yml:60-71) already runsgo test ./...onmacos-latestwith no-short, which means everyTestMainscenario runs. One green run answers unknowns 1–3. - Read the log, not just the exit code: confirm the new scenario’s result
string appears (a skip looks like a pass in some reporters —
requireGUIexists for that reason,webview_darwin_test.go:94-98). - Only then plumb:
webframe.Frame.Snapshot(), then the"snapshot"host op, thenSession.Screenshot’s darwin branch; finish withgo run ./cmd/runvm doctorandgo run ./cmd/runvm selftestonmacos-latest, which runvm’splatformsjob already executes (.github/workflows/ci.yml:104-170) —selftesttoday exits 0 with a warning when the platform reports “not supported”, so a real PNG is a visible behavior change, not a silent one. - Optional but cheap: run the same scenario under
go test -run TestSnapshot -count=1in a loop of ~20 on the runner to shake out the retain/release race in the block lifetime (§6.3).
Verdict
Likely-works.
- The only structurally new thing — passing a Go block to WebKit and having it
called back — is already implemented at
webview_darwin.go:1436-1440and is already exercised against a real WKWebView completion handler onmacos-latest(find_test.go). Nothing abouttakeSnapshot’s ABI differs fromfindString:withConfiguration:completionHandler:except an extra object argument in the block, whichpurego’sencodehandles by construction (objc_block_darwin.go:111-145). - The
NSImage→TIFFRepresentation→NSBitmapImageRep→representationUsingType:properties:chain is plainid-returning message sends; no struct returns, no_stret, no new classes, no cgo. - The residual risk is behavioral, not structural: whether the pixels are real
for a window glaze only sort-of shows, and whether the completion is delivered
promptly under
Run(). Both are one CI run away from being answered. - The genuinely hard part is not in glaze:
runvmcurrently captures from the MCP server process with OS-level tools, and on macOS the pixels are only reachable inside the page-host process, behind an unexportedwebframefield (§7). Budget for two fork bumps (glaze, webframe) plus a host-protocol op, not one function. - Needs-a-Mac-to-develop is not the right label: it can be written and
compile-checked from Linux, and verified by pushing a branch that the existing
macos-latestjob already tests. It is, however, needs-a-Mac-to-debug if the first run comes back blank. - First thing to try: add
snapshotScenario()towebview_darwin_test.gotogether with the ~60-linesnapshotAsync+pngFromNSImageabove, and push it. Do not touchwebframe, the host protocol, orrunvmuntil that run prints a PNG header and a non-zero ink sum.