{"record":{"id":"e14b6e38132f0bb8","repo":"microsoft/playwright","slug":"screencast-is-already-running","errorCode":null,"errorMessage":"Screencast is already running","messagePattern":"Screencast is already running","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/dispatchers/pageDispatcher.ts","lineNumber":399,"sourceCode":"  async screencastChapter(params: channels.PageScreencastChapterParams): Promise<channels.PageScreencastChapterResult> {\n    await this._page.overlay.chapter(params);\n  }\n\n  async screencastSetOverlayVisible(params: channels.PageScreencastSetOverlayVisibleParams): Promise<channels.PageScreencastSetOverlayVisibleResult> {\n    await this._page.overlay.setVisible(params.visible);\n  }\n\n  async screencastShowActions(params: channels.PageScreencastShowActionsParams): Promise<channels.PageScreencastShowActionsResult> {\n    this._page.screencast.showActions({ duration: params.duration, position: params.position, fontSize: params.fontSize, cursor: params.cursor });\n  }\n\n  async screencastHideActions(): Promise<channels.PageScreencastHideActionsResult> {\n    this._page.screencast.hideActions();\n  }\n\n  async screencastStart(params: channels.PageScreencastStartParams, progress?: Progress): Promise<channels.PageScreencastStartResult> {\n    if (this._screencastClient || this._videoRecorder)\n      throw new Error('Screencast is already running');\n\n    if (params.sendFrames) {\n      this._screencastClient = {\n        onFrame: async (frame: ScreencastFrame) => {\n          const frameId = ++this._screencastFrameId;\n          const promise = new ManualPromise<void>();\n          this._screencastFrameAcks.set(frameId, promise);\n          this._dispatchEvent('screencastFrame', { frameId, data: frame.buffer, timestamp: frame.frameSwapWallTime, viewportWidth: frame.viewportWidth, viewportHeight: frame.viewportHeight });\n          await promise;\n        },\n        gracefulClose: () => this._clearScreencastFrameAcks(),\n        dispose: () => this._clearScreencastFrameAcks(),\n        size: params.size,\n        quality: params.quality,\n      };\n      this._page.screencast.addClient(this._screencastClient);\n    }\n","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts#L381-L417","documentation":"Only one active frame-capture mechanism is allowed per page at a time. PageDispatcher.screencastStart throws when either _screencastClient (an in-progress MCP/protocol screencast) or _videoRecorder (a context-level video recording) is already set. The two subsystems share the page's frame producer and cannot run concurrently.","triggerScenarios":"Calling screencastStart a second time without first calling screencastStop; starting a page screencast while the browser context was created with recordVideo; starting recordVideo after a screencast is already streaming frames.","commonSituations":"MCP tooling that starts a screencast for visual feedback while the test config also has use: { recordVideo: { dir } }; a previous test's screencast was not stopped because the test errored mid-way; re-invoking a screencast command on a page that already has one running.","solutions":["Call screencastStop (or page._screencast.stop) before starting a new screencast on the same page.","Do not combine context.recordVideo with page-level screencast — pick one capture mechanism.","Wrap screencast usage in try/finally so screencastStop always runs even on test failure.","Use a fresh page for each screencast session if stop ordering is hard to guarantee."],"exampleFix":"// before\nawait page.screencastStart({ format: 'jpeg', quality: 80 });\n// ...later, another call without stop\nawait page.screencastStart({ format: 'jpeg', quality: 80 }); // throws\n// after\nawait page.screencastStart({ format: 'jpeg', quality: 80 });\ntry { /* ... */ } finally { await page.screencastStop(); }\nawait page.screencastStart({ format: 'jpeg', quality: 80 });","handlingStrategy":"validation","validationCode":"// Stop any running screencast before starting a new one.\nawait page.screencastStop().catch(() => {});\nawait page.screencastStart({ format: 'jpeg', quality: 80 });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not combine context.recordVideo with page screencast.","Wrap screencast use in try/finally and always call screencastStop.","Start each screencast on a fresh page if stop ordering is uncertain."],"tags":["screencast","video","resource-conflict"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}