File tree 3 files changed +25
-9
lines changed
packages/rrweb/src/replay
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 {
1303
1303
return this . debugNodeNotFound ( d , d . id ) ;
1304
1304
}
1305
1305
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
+ }
1314
1317
break ;
1315
1318
}
1316
1319
case IncrementalSource . StyleSheetRule :
Original file line number Diff line number Diff line change @@ -210,6 +210,12 @@ export class MediaManager {
210
210
const target = node as HTMLMediaElement ;
211
211
const serializedNode = mirror . getMeta ( target ) ;
212
212
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
+
213
219
const playerIsPaused = this . service . state . matches ( 'paused' ) ;
214
220
const mediaAttributes = serializedNode . attributes as
215
221
| mediaAttributes
@@ -285,7 +291,9 @@ export class MediaManager {
285
291
this . syncTargetWithState ( target ) ;
286
292
}
287
293
288
- public isSupportedMediaElement ( node : Node ) : node is HTMLMediaElement {
294
+ public isSupportedMediaElement (
295
+ node : Node | RRMediaElement ,
296
+ ) : node is HTMLMediaElement | RRMediaElement {
289
297
return [ 'AUDIO' , 'VIDEO' ] . includes ( node . nodeName ) ;
290
298
}
291
299
You can’t perform that action at this time.
0 commit comments