File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,9 @@ export default class CaptureContext {
180
180
return ____screencastCompleted ( ) ;
181
181
182
182
}
183
+ // 跳过无需捕获的帧
184
+ else
185
+ await ____skipFrame ( ) ;
183
186
184
187
// 开始捕获下一帧
185
188
nextFrame . bind ( this ) ( ) ;
Original file line number Diff line number Diff line change @@ -485,6 +485,8 @@ export default class Page extends EventEmitter {
485
485
await this . target . exposeFunction ( "____screencastCompleted" , this . #emitScreencastCompleted. bind ( this ) ) ;
486
486
// 暴露CSS动画控制函数
487
487
await this . target . exposeFunction ( "____seekCSSAnimations" , this . #seekCSSAnimations. bind ( this ) ) ;
488
+ // 暴露跳帧函数
489
+ await this . target . exposeFunction ( "____skipFrame" , this . #skipFrame. bind ( this ) ) ;
488
490
// 暴露下一帧函数
489
491
await this . target . exposeFunction ( "____captureFrame" , this . #captureFrame. bind ( this ) ) ;
490
492
// 暴露添加音频函数
@@ -539,6 +541,27 @@ export default class Page extends EventEmitter {
539
541
await Promise . all ( seekPromises ) ;
540
542
}
541
543
544
+ /**
545
+ * 跳过帧
546
+ */
547
+ async #skipFrame( ) {
548
+ if ( globalConfig . compatibleRenderingMode )
549
+ return ;
550
+ let timer ;
551
+ // 帧数据捕获
552
+ const frameData = await Promise . race ( [
553
+ this . #cdpSession. send ( "HeadlessExperimental.beginFrame" ) ,
554
+ // 帧渲染超时处理
555
+ new Promise ( resolve => timer = setTimeout ( ( ) => resolve ( false ) , this . beginFrameTimeout ) )
556
+ ] ) ;
557
+ clearTimeout ( timer ) ;
558
+ // 帧渲染超时处理
559
+ if ( frameData === false ) {
560
+ this . #setState( Page . STATE . UNAVAILABLED ) ;
561
+ throw new Error ( "beginFrame wait timeout" ) ;
562
+ }
563
+ }
564
+
542
565
/**
543
566
* 捕获帧
544
567
*/
You can’t perform that action at this time.
0 commit comments