Skip to content

fix: prevent invalid media processing#44

Merged
pendo-ops merged 1 commit intopendo-mainfrom
jc-prevent-invalid-media-processing
Apr 25, 2025
Merged

fix: prevent invalid media processing#44
pendo-ops merged 1 commit intopendo-mainfrom
jc-prevent-invalid-media-processing

Conversation

@juliecheng
Copy link

two main updates to media processing in this PR:

  1. protect against MediaInteraction events (mutations) being applied to non-media elements otherwise we'll see errors during playback
  2. exit early out of addMediaElements if a media element is blocked

@kode-toad
Copy link

kode-toad bot commented Apr 24, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

b17a66e

3 similar comments
@kode-toad
Copy link

kode-toad bot commented Apr 24, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

b17a66e

@kode-toad
Copy link

kode-toad bot commented Apr 24, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

b17a66e

@kode-toad
Copy link

kode-toad bot commented Apr 24, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

b17a66e

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR prevents errors during playback by ensuring that non-media elements and blocked media elements do not undergo media processing.

  • Returns early from media processing if a media element is flagged as blocked.
  • Verifies that media mutations are only applied to supported media elements.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/rrweb/src/replay/media/index.ts Adds an early exit in addMediaElements when a media element is blocked.
packages/rrweb/src/replay/index.ts Processes media mutations only for supported media elements.
.changeset/tiny-rabbits-chew.md Updates the changeset to reflect the media processing changes.

if (!serializedNode || !('attributes' in serializedNode)) return;

// don't process if the media element is blocked
const isBlockedMediaElement = serializedNode.attributes.rr_width || serializedNode.attributes.rr_height;
Copy link

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider verifying the condition explicitly in case rr_width or rr_height are 0, which may be a valid value. Using an explicit comparison (e.g. !== undefined) may prevent unintended early returns.

Suggested change
const isBlockedMediaElement = serializedNode.attributes.rr_width || serializedNode.attributes.rr_height;
const isBlockedMediaElement =
serializedNode.attributes.rr_width !== undefined || serializedNode.attributes.rr_height !== undefined;

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not concerned with this since rr_width and rr_height is always a string so it would be "0px" for 0 anyway

@kode-toad
Copy link

kode-toad bot commented Apr 24, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

b17a66e
4ab5ebf

@juliecheng juliecheng force-pushed the jc-prevent-invalid-media-processing branch from 4ab5ebf to 2609440 Compare April 25, 2025 18:42
@kode-toad
Copy link

kode-toad bot commented Apr 25, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

2609440

@kode-toad
Copy link

kode-toad bot commented Apr 25, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

2609440
4ea09b3

@juliecheng juliecheng changed the title Prevent invalid media processing fix: prevent invalid media processing Apr 25, 2025
@juliecheng juliecheng force-pushed the jc-prevent-invalid-media-processing branch from 4ea09b3 to c283cbd Compare April 25, 2025 20:11
@kode-toad
Copy link

kode-toad bot commented Apr 25, 2025

Failed pendo.io/jira-ref check. Please correct Jira references in the following commits:

c283cbd

@guntherjh
Copy link

[merge]

@pendo-ops pendo-ops merged commit 81da5b1 into pendo-main Apr 25, 2025
7 of 12 checks passed
@kode-toad
Copy link

kode-toad bot commented Apr 25, 2025

Branch jc-prevent-invalid-media-processing deleted

@kode-toad kode-toad bot deleted the jc-prevent-invalid-media-processing branch April 25, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants