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 @@ -1303,14 +1303,17 @@ export class Replayer {
13031303 return this . debugNodeNotFound ( d , d . id ) ;
13041304 }
13051305 const mediaEl = target as HTMLMediaElement | RRMediaElement ;
1306- const { events } = this . service . state . context ;
1307-
1308- this . mediaManager . mediaMutation ( {
1309- target : mediaEl ,
1310- timeOffset : e . timestamp - events [ 0 ] . timestamp ,
1311- mutation : d ,
1312- } ) ;
1313-
1306+ // sometimes we receive MediaInteraction events on non-media elements (e.g. DIV)
1307+ // only process media mutations on supported media elements to prevent errors during playback
1308+ if ( this . mediaManager . isSupportedMediaElement ( mediaEl ) ) {
1309+ const { events } = this . service . state . context ;
1310+
1311+ this . mediaManager . mediaMutation ( {
1312+ target : mediaEl ,
1313+ timeOffset : e . timestamp - events [ 0 ] . timestamp ,
1314+ mutation : d ,
1315+ } ) ;
1316+ }
13141317 break ;
13151318 }
13161319 case IncrementalSource . StyleSheetRule :
Original file line number Diff line number Diff line change @@ -210,6 +210,12 @@ export class MediaManager {
210210 const target = node as HTMLMediaElement ;
211211 const serializedNode = mirror . getMeta ( target ) ;
212212 if ( ! serializedNode || ! ( 'attributes' in serializedNode ) ) return ;
213+
214+ // don't process if the media element is blocked
215+ const isBlockedMediaElement =
216+ serializedNode . attributes . rr_width || serializedNode . attributes . rr_height ;
217+ if ( isBlockedMediaElement ) return ;
218+
213219 const playerIsPaused = this . service . state . matches ( 'paused' ) ;
214220 const mediaAttributes = serializedNode . attributes as
215221 | mediaAttributes
@@ -285,7 +291,9 @@ export class MediaManager {
285291 this . syncTargetWithState ( target ) ;
286292 }
287293
288- public isSupportedMediaElement ( node : Node ) : node is HTMLMediaElement {
294+ public isSupportedMediaElement (
295+ node : Node | RRMediaElement ,
296+ ) : node is HTMLMediaElement | RRMediaElement {
289297 return [ 'AUDIO' , 'VIDEO' ] . includes ( node . nodeName ) ;
290298 }
291299
You can’t perform that action at this time.
0 commit comments