mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(screencast): wait for ffmpeg to finish before reporting video (#6167)
This commit is contained in:
parent
957abc49e9
commit
f3b44d18be
@ -107,10 +107,10 @@ export abstract class Browser extends SdkObject {
|
||||
});
|
||||
}
|
||||
|
||||
_videoFinished(videoId: string) {
|
||||
_takeVideo(videoId: string): Artifact | undefined {
|
||||
const video = this._idToVideo.get(videoId);
|
||||
this._idToVideo.delete(videoId);
|
||||
video?.artifact.reportFinished();
|
||||
return video?.artifact;
|
||||
}
|
||||
|
||||
_didClose() {
|
||||
|
||||
@ -233,6 +233,14 @@ export abstract class BrowserContext extends SdkObject {
|
||||
|
||||
await this.instrumentation.onContextWillDestroy(this);
|
||||
|
||||
// Cleanup.
|
||||
const promises: Promise<void>[] = [];
|
||||
for (const { context, artifact } of this._browser._idToVideo.values()) {
|
||||
// Wait for the videos to finish.
|
||||
if (context === this)
|
||||
promises.push(artifact.finishedPromise());
|
||||
}
|
||||
|
||||
if (this._isPersistentContext) {
|
||||
// Close all the pages instead of the context,
|
||||
// because we cannot close the default context.
|
||||
@ -242,13 +250,6 @@ export abstract class BrowserContext extends SdkObject {
|
||||
await this._doClose();
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
const promises: Promise<void>[] = [];
|
||||
for (const { context, artifact } of this._browser._idToVideo.values()) {
|
||||
// Wait for the videos to finish.
|
||||
if (context === this)
|
||||
promises.push(artifact.finishedPromise());
|
||||
}
|
||||
// We delete downloads after context closure
|
||||
// so that browser does not write to the download file anymore.
|
||||
promises.push(this._deleteAllDownloads());
|
||||
|
||||
@ -900,9 +900,10 @@ class FrameSession {
|
||||
this._screencastId = null;
|
||||
const recorder = this._videoRecorder!;
|
||||
this._videoRecorder = null;
|
||||
const video = this._crPage._browserContext._browser._takeVideo(screencastId);
|
||||
await this._stopScreencast(recorder);
|
||||
await recorder.stop().catch(() => {});
|
||||
this._crPage._browserContext._browser._videoFinished(screencastId);
|
||||
video?.reportFinished();
|
||||
}
|
||||
|
||||
async _startScreencast(client: any, options: Protocol.Page.startScreencastParameters = {}) {
|
||||
|
||||
@ -134,7 +134,7 @@ export class FFBrowser extends Browser {
|
||||
}
|
||||
|
||||
_onScreencastFinished(payload: Protocol.Browser.screencastFinishedPayload) {
|
||||
this._videoFinished(payload.screencastId);
|
||||
this._takeVideo(payload.screencastId)?.reportFinished();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ export class WKBrowser extends Browser {
|
||||
}
|
||||
|
||||
_onScreencastFinished(payload: Protocol.Playwright.screencastFinishedPayload) {
|
||||
this._videoFinished(payload.screencastId);
|
||||
this._takeVideo(payload.screencastId)?.reportFinished();
|
||||
}
|
||||
|
||||
_onPageProxyCreated(event: Protocol.Playwright.pageProxyCreatedPayload) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user