Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/playwright-core/src/server/chromium/crPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,13 @@ export class CRPage implements PageDelegate {
return this._sessionForHandle(handle)._scrollRectIntoViewIfNeeded(handle, rect);
}

startScreencast(options: { width: number; height: number; quality: number; }) {
startScreencast(options: { width: number; height: number; quality: number; fps?: number }) {
this._mainFrameSession._client.send('Page.startScreencast', {
format: 'jpeg',
quality: options.quality,
maxWidth: options.width,
maxHeight: options.height,
maxFramesInFlight: (options.fps ?? 0) > 30 ? 10 : 5,
}).catch(() => {});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ export class PageDispatcher extends Dispatcher<Page, channels.PageChannel, Brows
dispose: () => this._clearScreencastFrameAcks(),
size: params.size,
quality: params.quality,
fps: params.fps,
};
this._page.screencast.addClient(this._screencastClient);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface PageDelegate {
getBoundingBox(handle: dom.ElementHandle): Promise<types.Rect | null>;
getFrameElement(frame: frames.Frame): Promise<dom.ElementHandle>;
scrollRectIntoViewIfNeeded(handle: dom.ElementHandle, rect?: types.Rect): Promise<'error:notvisible' | 'error:notconnected' | 'done'>;
startScreencast(options: { width: number, height: number, quality: number }): void;
startScreencast(options: { width: number, height: number, quality: number, fps?: number }): void;
stopScreencast(): void;

pdf?: (options: channels.PagePdfParams) => Promise<Buffer>;
Expand Down
6 changes: 4 additions & 2 deletions packages/playwright-core/src/server/screencast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type ScreencastClient = {
dispose: () => void;
size?: types.Size;
quality?: number;
fps?: number;
};

type AnnotatePosition = 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right';
Expand Down Expand Up @@ -113,7 +114,7 @@ export class Screencast implements InstrumentationListener {
const isFirst = this._clients.size === 0;
this._clients.set(client, new LongStandingScope());
if (isFirst) {
this._startScreencast(client.size, client.quality);
this._startScreencast(client.size, client.quality, client.fps);
} else if (this._lastFrame) {
// Deliver the cached last frame to the new client so it does not have
// to wait for the next browser repaint. setTimeout(0) ensures the caller
Expand All @@ -138,7 +139,7 @@ export class Screencast implements InstrumentationListener {
this._stopScreencast();
}

private _startScreencast(size: types.Size | undefined, quality: number | undefined) {
private _startScreencast(size: types.Size | undefined, quality: number | undefined, fps: number | undefined) {
this._size = size;
if (!this._size) {
const viewport = this.page.browserContext._options.viewport || { width: 800, height: 600 };
Expand All @@ -159,6 +160,7 @@ export class Screencast implements InstrumentationListener {
width: this._size.width,
height: this._size.height,
quality: quality ?? 90,
fps,
});
}

Expand Down
1 change: 1 addition & 0 deletions packages/playwright-core/src/server/videoRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class VideoRecorder {
gracefulClose: () => this.stop(),
dispose: () => this.stop().catch(e => debugLogger.log('error', `Failed to stop video recorder: ${String(e)}`)),
size: options.size,
fps: options.fps,
};

const { size } = this._screencast.addClient(this._client);
Expand Down
Loading