fix: wait for ffmpeg to finish writing even if page was closed (#6648)
This commit is contained in:
parent
e804d16dce
commit
b94643786b
|
|
@ -900,9 +900,11 @@ class FrameSession {
|
||||||
this._screencastId = null;
|
this._screencastId = null;
|
||||||
const recorder = this._videoRecorder!;
|
const recorder = this._videoRecorder!;
|
||||||
this._videoRecorder = null;
|
this._videoRecorder = null;
|
||||||
const video = this._crPage._browserContext._browser._takeVideo(screencastId);
|
|
||||||
await this._stopScreencast(recorder);
|
await this._stopScreencast(recorder);
|
||||||
await recorder.stop().catch(() => {});
|
await recorder.stop().catch(() => {});
|
||||||
|
// Keep the video artifact in the map utntil encoding is fully finished, if the context
|
||||||
|
// starts closing before the video is fully written to disk it will wait for it.
|
||||||
|
const video = this._crPage._browserContext._browser._takeVideo(screencastId);
|
||||||
video?.reportFinished();
|
video?.reportFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -615,4 +615,32 @@ it.describe('screencast', () => {
|
||||||
const saveResult = await page.video().saveAs(file).catch(e => e);
|
const saveResult = await page.video().saveAs(file).catch(e => e);
|
||||||
expect(saveResult.message).toContain('rowser has been closed');
|
expect(saveResult.message).toContain('rowser has been closed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should wait for video to finish if page was closed', async ({browserType, browserOptions, contextOptions}, testInfo) => {
|
||||||
|
const size = { width: 320, height: 240 };
|
||||||
|
const browser = await browserType.launch(browserOptions);
|
||||||
|
|
||||||
|
const videoDir = testInfo.outputPath('');
|
||||||
|
const context = await browser.newContext({
|
||||||
|
...contextOptions,
|
||||||
|
recordVideo: {
|
||||||
|
dir: videoDir,
|
||||||
|
size,
|
||||||
|
},
|
||||||
|
viewport: size,
|
||||||
|
});
|
||||||
|
|
||||||
|
const page = await context.newPage();
|
||||||
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
|
await page.close();
|
||||||
|
await context.close();
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
|
const videoFiles = findVideos(videoDir);
|
||||||
|
expect(videoFiles.length).toBe(1);
|
||||||
|
const videoPlayer = new VideoPlayer(videoFiles[0]);
|
||||||
|
expect(videoPlayer.videoWidth).toBe(320);
|
||||||
|
expect(videoPlayer.videoHeight).toBe(240);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue