fix(engine): bucket gpu_renderer + cover the failure cohort (review)

Three review findings on the win32 drawElement PR:

1. gpu_renderer shipped the raw UNMASKED_RENDERER_WEBGL string — unbounded,
   driver-authored, GPU-model-specific, and |-joined across parallel
   sessions, i.e. high cardinality by construction, against this file's own
   convention of sanitizing engine-sourced strings (deGateReason is a
   bucket; error messages go through redactTelemetryString). Now bucketed at
   the source by classifyGpuRenderer to <backend>/<vendor>
   (metal/apple, d3d11/nvidia, swiftshader/other, ...), which is the whole
   analytic signal the win32 rollout needs and nothing else. The raw string
   never leaves the engine.

2. gpu_renderer reached render_complete only, so a crashed render — the
   cohort the field exists to attribute — carried no backend. It now rides
   RenderCaptureObservability (deGpuRenderer, sourced from the live probe
   session like the de_* counters), so both render_complete and
   render_error carry it and a hard failure still reports its GPU backend.
   On render_complete the perfSummary value still wins by spread order.

3. Restore the fallow-ignore-next-line suppression above
   __resetDeParallelRouterTrialStateForTests: CLI test files are not fallow
   entry points, so removing it fails the CI dead-code audit (local
   pre-commit passed only because of its changed-file scope).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vance Ingalls
2026-07-28 00:55:10 -07:00
co-authored by Claude Opus 5
parent cb30157ebb
commit 4520cd240b
9 changed files with 120 additions and 17 deletions
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import type { Page } from "puppeteer-core";
import {
classifyGpuRenderer,
detectGpuBackend,
detectSwiftShader,
resolveDrawElementCaptureMode,
@@ -48,6 +49,42 @@ describe("detectGpuBackend", () => {
});
});
// ── classifyGpuRenderer ────────────────────────────────────────────────────────
describe("classifyGpuRenderer", () => {
it("buckets real ANGLE renderer strings to <backend>/<vendor>", () => {
expect(
classifyGpuRenderer("ANGLE (Apple, ANGLE Metal Renderer: Apple M4 Pro, Unspecified Version)"),
).toBe("metal/apple");
expect(
classifyGpuRenderer(
"ANGLE (NVIDIA, NVIDIA GeForce RTX 3080 Direct3D11 vs_5_0 ps_5_0, D3D11)",
),
).toBe("d3d11/nvidia");
expect(
classifyGpuRenderer("ANGLE (Intel, Intel(R) UHD Graphics 630 Direct3D11 vs_5_0 ps_5_0)"),
).toBe("d3d11/intel");
expect(classifyGpuRenderer("ANGLE (AMD, AMD Radeon RX 6800 Direct3D11 vs_5_0 ps_5_0)")).toBe(
"d3d11/amd",
);
expect(classifyGpuRenderer("Google SwiftShader")).toBe("swiftshader/other");
});
it("drops the GPU model — the bucket must stay low cardinality", () => {
// Two different NVIDIA cards must collapse to ONE bucket, otherwise the
// property is unbounded and useless for aggregation.
expect(classifyGpuRenderer("ANGLE (NVIDIA, NVIDIA GeForce RTX 4090 Direct3D11)")).toBe(
classifyGpuRenderer("ANGLE (NVIDIA, NVIDIA GeForce GTX 1060 Direct3D11)"),
);
});
it("returns undefined for missing input rather than a bogus bucket", () => {
expect(classifyGpuRenderer(null)).toBeUndefined();
expect(classifyGpuRenderer(undefined)).toBeUndefined();
expect(classifyGpuRenderer("")).toBeUndefined();
});
});
// ── resolveDrawElementCaptureMode ──────────────────────────────────────────────
describe("resolveDrawElementCaptureMode", () => {
@@ -110,15 +110,58 @@ export interface GpuBackendInfo {
isSwiftShader: boolean;
/**
* Raw UNMASKED_RENDERER_WEBGL string (e.g. "ANGLE (Apple, ANGLE Metal
* Renderer: Apple M4 Pro, ...)", "ANGLE (NVIDIA, D3D11 ...)"), or null when
* WebGL / the debug extension is unavailable. Carried to render telemetry:
* drawElement failure modes proved compositor-backend-specific during the
* macOS rollout, so the win32/D3D11 cohort needs damage clusters
* attributable to a GPU vendor + ANGLE backend, not just `os`.
* Renderer: Apple M4 Pro, ...)", "ANGLE (NVIDIA, GeForce RTX 3080 Direct3D11
* vs_5_0 ps_5_0, D3D11)"), or null when WebGL / the debug extension is
* unavailable. LOCAL USE ONLY — this is unbounded driver-supplied text and
* must not be shipped to telemetry verbatim; send
* {@link classifyGpuRenderer}'s bucket instead.
*/
renderer: string | null;
}
/**
* Low-cardinality bucket for a raw WebGL renderer string: `<backend>/<vendor>`
* (e.g. `metal/apple`, `d3d11/nvidia`, `swiftshader/other`).
*
* drawElement failure modes proved compositor-backend-specific during the
* macOS rollout, so the win32/D3D11 cohort needs damage attributable to an
* ANGLE backend + GPU vendor. The raw string can't do that job in telemetry:
* it is unbounded, driver-authored, carries specific GPU model names, and is
* joined across parallel sessions — high cardinality by construction. The
* bucket keeps the analytic signal (which backend, which vendor) and drops
* everything else, matching how `deGateReason` is a sanitized bucket rather
* than the full fallback trigger. Pure; exported for tests.
*/
export function classifyGpuRenderer(renderer: string | null | undefined): string | undefined {
if (!renderer) return undefined;
const r = renderer.toLowerCase();
const backend = r.includes("swiftshader")
? "swiftshader"
: r.includes("metal")
? "metal"
: r.includes("direct3d11") || r.includes("d3d11")
? "d3d11"
: r.includes("direct3d9") || r.includes("d3d9")
? "d3d9"
: r.includes("vulkan")
? "vulkan"
: r.includes("opengl") || r.includes("angle")
? "opengl"
: "other";
const vendor = r.includes("apple")
? "apple"
: r.includes("nvidia")
? "nvidia"
: r.includes("amd") || r.includes("radeon")
? "amd"
: r.includes("intel")
? "intel"
: r.includes("microsoft")
? "microsoft"
: "other";
return `${backend}/${vendor}`;
}
/**
* Detect the page's WebGL backend: SwiftShader vs a real GPU, plus the raw
* renderer string for telemetry.
+8 -5
View File
@@ -34,6 +34,7 @@ import {
shouldDefaultCaptureBeyondViewport,
} from "./screenshotService.js";
import {
classifyGpuRenderer,
detectGpuBackend,
injectDrawElementCanvas,
captureDrawElementFrame,
@@ -147,10 +148,12 @@ export interface CaptureSession {
/** True if running on SwiftShader (detected at init). Undefined before init. */
isSwiftShader?: boolean;
/**
* Raw WebGL UNMASKED_RENDERER_WEBGL string, captured alongside the
* SwiftShader probe at DE session init (e.g. "ANGLE (NVIDIA, D3D11 ...)").
* Surfaces in CapturePerfSummary → render telemetry so backend-specific
* drawElement damage (Metal vs D3D11 vs GL) clusters attributably.
* Low-cardinality GPU bucket (`<backend>/<vendor>`, e.g. `d3d11/nvidia`)
* derived from the WebGL renderer at DE session init. Surfaces in
* CapturePerfSummary → render telemetry so backend-specific drawElement
* damage (Metal vs D3D11 vs GL) clusters attributably. The raw
* driver-supplied string is deliberately NOT retained — see
* classifyGpuRenderer.
*/
gpuRenderer?: string;
/** drawElementImage canvas was injected and is ready for capture. */
@@ -713,7 +716,7 @@ async function initDrawElementOrTransparentBackground(
if (useDrawElement) {
const gpuBackend = await detectGpuBackend(page);
session.isSwiftShader = gpuBackend.isSwiftShader;
session.gpuRenderer = gpuBackend.renderer ?? undefined;
session.gpuRenderer = classifyGpuRenderer(gpuBackend.renderer);
const transparent = session.options.format === "png";
async function routeToFallback(): Promise<void> {
session.captureMode = session.launchCaptureMode;