From 67d1f7195cd676cd71cbb5e9611ae78dfffc82c0 Mon Sep 17 00:00:00 2001 From: Vance Ingalls Date: Mon, 27 Apr 2026 19:57:52 -0700 Subject: [PATCH] fix(hdr): route identity-matrix HDR elements through region blit for clip rect support parseTransformMatrix returns a valid matrix even for untransformed HDR elements (Chrome reports matrix(1,0,0,1,0,0)). This made the affine blit path always run, bypassing the region blit path which is the only one that applies clip rects from overflow:hidden ancestors. Fix: detect identity matrices and route them through the region path so the cropRgb48le clip logic is reachable for split-screen layouts. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../producer/src/services/renderOrchestrator.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/producer/src/services/renderOrchestrator.ts b/packages/producer/src/services/renderOrchestrator.ts index b855107f0c..e59ef581be 100644 --- a/packages/producer/src/services/renderOrchestrator.ts +++ b/packages/producer/src/services/renderOrchestrator.ts @@ -578,7 +578,22 @@ function blitHdrVideoLayer( clipped = true; } - if (viewportMatrix) { + // Detect identity matrix — route through the region path (which supports + // clip rects) instead of the affine path. Chrome reports a viewport matrix + // for all HDR elements, including untransformed ones inside overflow:hidden + // wrappers. An identity matrix means no visual transform is applied. + const isIdentity = !!( + viewportMatrix && + viewportMatrix.length >= 6 && + Math.abs(viewportMatrix[0]! - 1) < 0.001 && + Math.abs(viewportMatrix[1]!) < 0.001 && + Math.abs(viewportMatrix[2]!) < 0.001 && + Math.abs(viewportMatrix[3]! - 1) < 0.001 && + Math.abs(viewportMatrix[4]!) < 0.001 && + Math.abs(viewportMatrix[5]!) < 0.001 + ); + + if (viewportMatrix && !isIdentity) { if (clipped && log) { log.debug( `HDR clip rect on affine-transformed element ${el.id} — clip not applied (affine scissor not yet supported)`,