Skip to content

Commit

Permalink
fix(screencast): remove white padding in headless chromium (#3746)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s authored Sep 3, 2020
1 parent de547d7 commit 0976732
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 11 additions & 9 deletions src/server/chromium/crPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,17 @@ class FrameSession {
}),
];
if (this._windowId) {
// TODO: popup windows have their own insets.
let insets = { width: 24, height: 88 };
if (process.platform === 'win32')
insets = { width: 16, height: 88 };
else if (process.platform === 'linux')
insets = { width: 8, height: 85 };
else if (process.platform === 'darwin')
insets = { width: 2, height: 80 };

let insets = { width: 0, height: 0 };
if (this._crPage._browserContext._browser._options.headful) {
// TODO: popup windows have their own insets.
insets = { width: 24, height: 88 };
if (process.platform === 'win32')
insets = { width: 16, height: 88 };
else if (process.platform === 'linux')
insets = { width: 8, height: 85 };
else if (process.platform === 'darwin')
insets = { width: 2, height: 80 };
}
promises.push(this._client.send('Browser.setWindowBounds', {
windowId: this._windowId,
bounds: { width: viewportSize.width + insets.width, height: viewportSize.height + insets.height }
Expand Down
2 changes: 1 addition & 1 deletion src/server/chromium/videoRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class VideoRecorder {
assert(!this._isRunning());
const w = options.width;
const h = options.height;
const args = `-f image2pipe -c:v mjpeg -i - -y -an -r ${fps} -c:v vp8 -vf pad=${w}:${h}:0:0:gray,crop=${w}:${h}:0:0`.split(' ');
const args = `-loglevel error -f image2pipe -c:v mjpeg -i - -y -an -r ${fps} -c:v vp8 -vf pad=${w}:${h}:0:0:gray,crop=${w}:${h}:0:0`.split(' ');
args.push(options.outputFile);
const progress = this._progress;
// Use ffmpeg provided by the host system.
Expand Down
4 changes: 1 addition & 3 deletions test/screencast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ describe('screencast', suite => {
await context.close();
});

it('should scale frames down to the requested size ', test => {
test.fixme(options.CHROMIUM && options.HEADLESS, 'Window is not resized when changing viewport');
}, async ({page, videoPlayer, tmpDir, server, toImpl}) => {
it('should scale frames down to the requested size ', async ({page, videoPlayer, tmpDir, server, toImpl}) => {
await page.setViewportSize({width: 640, height: 480});
const videoFile = path.join(tmpDir, 'v.webm');
await page.goto(server.PREFIX + '/checkerboard.html');
Expand Down

0 comments on commit 0976732

Please sign in to comment.