File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
packages/rrweb/src/replay Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " rrweb " : patch
3+ ---
4+
5+ Make sure MediaInteraction events / mutations are only processed on MediaElements + exit early in addMediaElements if a MediaElement is a blocked element
Original file line number Diff line number Diff line change @@ -1311,14 +1311,17 @@ export class Replayer {
13111311 return this . debugNodeNotFound ( d , d . id ) ;
13121312 }
13131313 const mediaEl = target as HTMLMediaElement | RRMediaElement ;
1314- const { events } = this . service . state . context ;
1315-
1316- this . mediaManager . mediaMutation ( {
1317- target : mediaEl ,
1318- timeOffset : e . timestamp - events [ 0 ] . timestamp ,
1319- mutation : d ,
1320- } ) ;
1321-
1314+ // sometimes we receive MediaInteraction events on non-media elements (e.g. DIV)
1315+ // only process media mutations on supported media elements to prevent errors during playback
1316+ if ( this . mediaManager . isSupportedMediaElement ( mediaEl ) ) {
1317+ const { events } = this . service . state . context ;
1318+
1319+ this . mediaManager . mediaMutation ( {
1320+ target : mediaEl ,
1321+ timeOffset : e . timestamp - events [ 0 ] . timestamp ,
1322+ mutation : d ,
1323+ } ) ;
1324+ }
13221325 break ;
13231326 }
13241327 case IncrementalSource . StyleSheetRule :
Original file line number Diff line number Diff line change @@ -209,6 +209,12 @@ export class MediaManager {
209209 const target = node as HTMLMediaElement ;
210210 const serializedNode = mirror . getMeta ( target ) ;
211211 if ( ! serializedNode || ! ( 'attributes' in serializedNode ) ) return ;
212+
213+ // don't process if the media element is blocked
214+ const isBlockedMediaElement =
215+ serializedNode . attributes . rr_width || serializedNode . attributes . rr_height ;
216+ if ( isBlockedMediaElement ) return ;
217+
212218 const playerIsPaused = this . service . state . matches ( 'paused' ) ;
213219 const mediaAttributes = serializedNode . attributes as
214220 | mediaAttributes
@@ -284,7 +290,9 @@ export class MediaManager {
284290 this . syncTargetWithState ( target ) ;
285291 }
286292
287- public isSupportedMediaElement ( node : Node ) : node is HTMLMediaElement {
293+ public isSupportedMediaElement (
294+ node : Node | RRMediaElement ,
295+ ) : node is HTMLMediaElement | RRMediaElement {
288296 return [ 'AUDIO' , 'VIDEO' ] . includes ( node . nodeName ) ;
289297 }
290298
You can’t perform that action at this time.
0 commit comments