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 {
1311
1311
return this . debugNodeNotFound ( d , d . id ) ;
1312
1312
}
1313
1313
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
+ }
1322
1325
break ;
1323
1326
}
1324
1327
case IncrementalSource . StyleSheetRule :
Original file line number Diff line number Diff line change @@ -209,6 +209,12 @@ export class MediaManager {
209
209
const target = node as HTMLMediaElement ;
210
210
const serializedNode = mirror . getMeta ( target ) ;
211
211
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
+
212
218
const playerIsPaused = this . service . state . matches ( 'paused' ) ;
213
219
const mediaAttributes = serializedNode . attributes as
214
220
| mediaAttributes
@@ -284,7 +290,9 @@ export class MediaManager {
284
290
this . syncTargetWithState ( target ) ;
285
291
}
286
292
287
- public isSupportedMediaElement ( node : Node ) : node is HTMLMediaElement {
293
+ public isSupportedMediaElement (
294
+ node : Node | RRMediaElement ,
295
+ ) : node is HTMLMediaElement | RRMediaElement {
288
296
return [ 'AUDIO' , 'VIDEO' ] . includes ( node . nodeName ) ;
289
297
}
290
298
You can’t perform that action at this time.
0 commit comments