:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(replay): scale the player frame when no snapshot resize fires (#82433)
posthog[bot]a4171cddc22d
diff --git a/frontend/src/scenes/session-recordings/player/PlayerFrame.scss b/frontend/src/scenes/session-recordings/player/PlayerFrame.scssindex 7e332858c0e4..d1018e8a8054 100644--- a/frontend/src/scenes/session-recordings/player/PlayerFrame.scss+++ b/frontend/src/scenes/session-recordings/player/PlayerFrame.scss@@ -24,6 +24,12 @@.PlayerFrame__content {position: absolute;+ // Center the frame so a letterboxed or not-yet-scaled recording sits in the+ // middle of the player rather than pinned to the top-left corner.+ top: 50%;+ left: 50%;+ transform: translate(-50%, -50%);+iframe {background-color: white;border: 0;diff --git a/frontend/src/scenes/session-recordings/player/PlayerFrame.tsx b/frontend/src/scenes/session-recordings/player/PlayerFrame.tsxindex 10864f1ca9c9..8f9bcc36d889 100644--- a/frontend/src/scenes/session-recordings/player/PlayerFrame.tsx+++ b/frontend/src/scenes/session-recordings/player/PlayerFrame.tsx@@ -13,7 +13,7 @@ const BASE_CLICK_INDICATOR_DURATION_S = 1 / 3export const PlayerFrame = (): JSX.Element => {const replayDimensionRef = useRef<viewportResizeDimension>()- const { player, sessionRecordingId, maskingWindow, speed } = useValues(sessionRecordingPlayerLogic)+ const { player, sessionRecordingId, maskingWindow, speed, resolution } = useValues(sessionRecordingPlayerLogic)const { setScale, setRootFrame } = useActions(sessionRecordingPlayerLogic)const frameRef = useRef<HTMLDivElement | null>(null)@@ -23,16 +23,16 @@ export const PlayerFrame = (): JSX.Element => {// Define callbacks before they're used in effectsconst updatePlayerDimensions = useCallback((replayDimensions: viewportResizeDimension | undefined): void => {- if (- !replayDimensions ||- !frameRef?.current?.parentElement ||- !player?.replayer ||- !player?.replayer.wrapper- ) {+ // The rrweb replayer only reports dimensions through its `resize` event, which+ // never fires for a recording whose first full snapshot arrived late. Fall back+ // to the recording's known resolution so the frame still scales to its container.+ const dimensions = replayDimensions ?? resolution ?? undefined++ if (!dimensions || !frameRef?.current?.parentElement || !player?.replayer || !player?.replayer.wrapper) {return}- replayDimensionRef.current = replayDimensions+ replayDimensionRef.current = dimensionsconst parentDimensions = frameRef.current.parentElement.getBoundingClientRect()@@ -40,8 +40,8 @@ export const PlayerFrame = (): JSX.Element => {// an identity transform (scale(1)) causes the iframe layer to paint outside// its clipping bounds, overlapping the rest of the UI.const scale = Math.min(- parentDimensions.width / replayDimensions.width,- parentDimensions.height / replayDimensions.height,+ parentDimensions.width / dimensions.width,+ parentDimensions.height / dimensions.height,0.999)@@ -49,7 +49,7 @@ export const PlayerFrame = (): JSX.Element => {setScale(scale)},- [player, setScale]+ [player, setScale, resolution])const windowResize = useCallback((): void => {