fix(player): rescale on cross-origin timeline ready, guard warn spam (#1840)

onRuntimeTimelineReady (the cross-origin ready signal for signed CDN
composition URLs) never called _rescale(), leaving the iframe unscaled
and untransformed if the runtime's stage-size postMessage was ever
skipped. Also adds a one-shot diagnostic warning when a rescale keeps
no-oping after ready, latched so a legitimately hidden/zero-size player
doesn't spam the console.
This commit is contained in:
Vance Ingalls
2026-07-01 14:36:48 -07:00
committed by GitHub
parent 24edb15095
commit e5ec4cf532
3 changed files with 63 additions and 3 deletions
+5 -2
View File
@@ -57,18 +57,21 @@ export function createCompositionIframe(): {
/**
* Scale the iframe so the composition fits inside the player element while
* preserving aspect ratio. No-ops when the player has no painted size yet.
* Returns whether the transform was actually applied, so callers can tell a
* real no-op (still 0×0) apart from a successful rescale.
*/
export function scaleIframeToFit(
playerElement: HTMLElement,
iframe: HTMLIFrameElement,
compositionWidth: number,
compositionHeight: number,
): void {
): boolean {
const w = playerElement.offsetWidth;
const h = playerElement.offsetHeight;
if (w === 0 || h === 0) return;
if (w === 0 || h === 0) return false;
const scale = Math.min(w / compositionWidth, h / compositionHeight);
iframe.style.width = `${compositionWidth}px`;
iframe.style.height = `${compositionHeight}px`;
iframe.style.transform = `translate(-50%, -50%) scale(${scale})`;
return true;
}