Follow-on to the CDP client. Three questions kept coming back unanswerable from the host side, so each now has a probe that asks the guest directly. `guest_gl_renderers.py` enumerates CGL renderers. On this guest the answer is one renderer, the Apple Software Renderer, `accelerated=0` — which is the whole explanation for every OpenGL-based browser reporting software rendering at once. Note the constants: `kCGLRP*` are small integers, and the first version of this file used the `kCGLPFA*` values in the 1600s by mistake, which makes `CGLDescribeRenderer` fail every query and reads as a dead GPU rather than a dead probe. `guest_metal_caps.py` reports the Metal device. It drives `objc_msgSend` through ctypes with explicit per-call argtypes — derived argtypes cannot express an out-parameter, since `ctypes.byref` yields a CArgObject with no `from_param`. `gpu-probe.html` + `probe_server.py` + `web-gpu-probe.sh` ask each browser whether WebGL/WebGPU came up and how many frames it sustained. The page posts its own result back to the server that served it: Safari has no debugging protocol, and AppleScript into Safari or Finder times out on this guest waiting for an automation-consent click that an unattended run cannot give. Serving over http rather than file:// is required for that POST to be same-origin. Measured with these, x86/Vulkan, macOS 13.7.8, one boot: Safari 16.6 WebGL1+2 "Apple GPU", hardware, 119.4 fps, worst frame 13 ms Chrome 151 WebGL1+2 unavailable, WebGPU no adapter, 134.6 fps rAF only Firefox 153 WebGL1+2 unavailable, no navigator.gpu, 122.5 fps rAF only So Metal works and the fault is not general. Chrome's GPU process exits during init with "Initialization of all (1) EGL display types failed", including when ANGLE is forced to Metal from a GUI-session launch with the blocklist ignored. The device is fully usable — it compiles MSL and creates a command queue — but `MTLCreateSystemDefaultDevice()` returns nil while `MTLCopyAllDevices()` returns it, and ANGLE-Metal asks for the system default. Tooling only; no crate code touched.
73 lines
2.6 KiB
Python
Executable File
73 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Serve the GPU probe page inside the guest and collect what it reports.
|
|
|
|
Runs inside the macOS guest, stdlib only.
|
|
|
|
The probe has to get its result out of a browser that may have no debugging
|
|
protocol (Safari) and no granted automation permission — AppleScript into
|
|
Safari or Finder times out on a fresh guest until someone clicks a consent
|
|
dialog, which an unattended run cannot do. Serving the page over HTTP and
|
|
letting it POST its own result back is the one channel that needs no consent
|
|
and works identically in Safari, Chrome and Firefox.
|
|
|
|
The page must be served over http rather than opened as a file:// URL, because
|
|
a file:// origin cannot POST to http://127.0.0.1.
|
|
|
|
python3 probe_server.py <port> <html-path> <result-path>
|
|
"""
|
|
|
|
import http.server
|
|
import json
|
|
import os
|
|
import sys
|
|
import threading
|
|
|
|
|
|
def make_handler(html_path, result_path):
|
|
class Handler(http.server.BaseHTTPRequestHandler):
|
|
def log_message(self, *_args):
|
|
pass # the guest console is the serial log; keep it clean
|
|
|
|
def do_GET(self):
|
|
path = self.path.split("?")[0]
|
|
if path in ("/", "/index.html", "/probe"):
|
|
body = open(html_path, "rb").read()
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "text/html; charset=utf-8")
|
|
self.send_header("Content-Length", str(len(body)))
|
|
# A stale probe page is indistinguishable from a probe that did
|
|
# not run, so never let the browser cache it.
|
|
self.send_header("Cache-Control", "no-store")
|
|
self.end_headers()
|
|
self.wfile.write(body)
|
|
return
|
|
self.send_error(404)
|
|
|
|
def do_POST(self):
|
|
n = int(self.headers.get("Content-Length", "0"))
|
|
raw = self.rfile.read(n)
|
|
with open(result_path, "ab") as f:
|
|
f.write(raw + b"\n")
|
|
self.send_response(204)
|
|
self.send_header("Content-Length", "0")
|
|
self.end_headers()
|
|
|
|
return Handler
|
|
|
|
|
|
def main():
|
|
port, html_path, result_path = int(sys.argv[1]), sys.argv[2], sys.argv[3]
|
|
if os.path.exists(result_path):
|
|
os.unlink(result_path)
|
|
srv = http.server.ThreadingHTTPServer(("127.0.0.1", port), make_handler(html_path, result_path))
|
|
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
|
print(f"serving http://127.0.0.1:{port}/ -> {result_path}", flush=True)
|
|
try:
|
|
threading.Event().wait()
|
|
except KeyboardInterrupt:
|
|
pass
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|