fix(capture): apply device viewport before tab-capture starts#804
Merged
Conversation
Tab capture pins exact width/height from the target device, so `getUserMedia` overconstrains and fails with OverconstrainedError when the page still has the browser's default viewport. `resolveViewport` computed the device viewport but never applied it before the extension mode started recording. Rename to `prepareViewport` and `page.setViewport(device.viewport)` before any mode starts, so the page always matches the constraints. Navigation still runs after recording starts, so load animations are captured from t=0. This centralizes the viewport application for all modes, making the frame recorder's own setViewport redundant. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
f57ccce to
b28298e
Compare
Member
|
Rebased onto current The original diff targeted Changes:
All 24 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
#803starts tab recording beforegotoruns. Tab-capture constraints pin exactminWidth/minHeight/maxWidth/maxHeightfrom the target device viewport. When the page still has the browser's default viewport (e.g. Macbook Pro 13 at 2560×1600) but capture requests a different device (e.g. iPhone 13 at 1170×2532),getUserMediacan fail withOverconstrainedErrorbecauseminHeight: 2532exceeds the tab's actual height (1600). Capture completely fails for a common custom-device use case.Root cause
resolveViewportcomputed constraints fromgoto.getDevice()but did not apply the viewport to the page beforeextension.startRecording()calledgetUserMediain the extension.goto'spage.setViewport()only ran later inside theonStartedhook.Fix
Rename to
prepareViewportand callpage.setViewport(device.viewport)before starting the recorder. Navigation still happens after recording starts, so load animations are captured from t=0.Validation
@browserless/capturetests passNote
Low Risk
Narrow timing fix in capture setup with a regression test; navigation and recording order are unchanged aside from earlier viewport application.
Overview
Fixes tab extension capture failing with
OverconstrainedErrorwhen a custom device viewport does not match the page’s default size beforegetUserMediaruns.prepareViewport(formerlyresolveViewport) nowawait page.setViewport(device.viewport)fromgoto.getDevice()before the recorder starts, while navigation still runs inonStartedafter recording begins. The shared ffmpeg recorder drops its redundant pre-framesetViewportand documents that sizing is applied upstream.Adds a regression test that asserts the device viewport is set at
START_RECORDING, not only aftergoto.Reviewed by Cursor Bugbot for commit b28298e. Bugbot is set up for automated code reviews on this repo. Configure here.