Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip addition of src attribute for HLS videos #1446

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions patches/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ index ea868845c4fad3276aa8e5f74abfd3568b466d11..965505de44975e718d431a4e9a62e753
/* eslint-enable */

export { WorkerFactory as default };
diff --git a/es/rrweb/packages/rrweb/src/record/mutation.js b/es/rrweb/packages/rrweb/src/record/mutation.js
index 30ea08b22210dde2f6e27c1adf83e0164a47554f..11334f600856e1ed7dcbdea28e8c2dc38a6b6742 100644
--- a/es/rrweb/packages/rrweb/src/record/mutation.js
+++ b/es/rrweb/packages/rrweb/src/record/mutation.js
@@ -386,7 +386,7 @@ class MutationBuffer {
(m.oldValue || '').toLowerCase() === 'password') {
target.setAttribute('data-rr-is-password', 'true');
}
- if (!ignoreAttribute(target.tagName, attributeName)) {
+ if (!ignoreAttribute(target.tagName, attributeName, value)) {
item.attributes[attributeName] = transformAttribute(this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value);
if (attributeName === 'style') {
if (!this.unattachedDoc) {
diff --git a/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js b/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
index da2c103fe6b1408a5996f0eb3bf047571e434cc2..f5b060c7e0728a3e2c6cf62b01d97282f2484ac3 100644
--- a/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
Expand Down Expand Up @@ -224,7 +237,7 @@ index da2c103fe6b1408a5996f0eb3bf047571e434cc2..f5b060c7e0728a3e2c6cf62b01d97282
}, [bitmap]);
}));
diff --git a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
index 0fc7d4bcafc9be822347f9437658478fd77d9972..bb4114b638b7d1173ef50b639a58de7d707c474f 100644
index 0fc7d4bcafc9be822347f9437658478fd77d9972..b5a59feb930d0582488f64f8509deb668ff3de56 100644
--- a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
+++ b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
@@ -48,7 +48,7 @@ function stringifyStylesheet(s) {
Expand All @@ -236,7 +249,19 @@ index 0fc7d4bcafc9be822347f9437658478fd77d9972..bb4114b638b7d1173ef50b639a58de7d
: null;
}
catch (error) {
@@ -641,9 +641,18 @@ function serializeElementNode(n, options) {
@@ -385,8 +385,9 @@ function transformAttribute(doc, tagName, name, value) {
}
return value;
}
-function ignoreAttribute(tagName, name, _value) {
- return (tagName === 'video' || tagName === 'audio') && name === 'autoplay';
+function ignoreAttribute(tagName, name, value) {
+ return (((tagName === 'video' || tagName === 'audio') && name === 'autoplay') ||
+ (tagName === 'video' && name === 'src' && value && value.startsWith('blob:http')));
}
function _isBlockedElement(element, blockClass, blockSelector) {
try {
@@ -641,9 +642,18 @@ function serializeElementNode(n, options) {
}
}
if (tagName === 'link' && inlineStylesheet) {
Expand Down
11 changes: 6 additions & 5 deletions playground/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@
"link-posthog-js": "cd ../../ && pnpm link --global && cd playground/nextjs && pnpm link --global posthog-js"
},
"dependencies": {
"@lottiefiles/react-lottie-player": "^3.5.3",
"@lottiefiles/react-lottie-player": "^3.5.4",
"@types/node": "18.13.0",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.10",
"cookie": "^0.6.0",
"eslint": "8.34.0",
"eslint-config-next": "13.1.6",
"hls.js": "^1.5.15",
"next": "13.5.6",
"posthog-js": "1.128.3",
"posthog-js": "1.166.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.9.5"
},
"devDependencies": {
"@types/cookie": "^0.6.0",
"autoprefixer": "^10.4.17",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1"
"autoprefixer": "^10.4.20",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.13"
}
}
30 changes: 29 additions & 1 deletion playground/nextjs/pages/replay-examples/media.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
import Hls from 'hls.js'
import { useEffect, useRef } from 'react'

export default function Media() {
const hlsVideoEl = useRef<HTMLVideoElement>(null)

useEffect(() => {
const videoEl = hlsVideoEl.current
if (videoEl) {
if (Hls.isSupported()) {
const hls = new Hls()
hls.loadSource('https://d2zihajmogu5jn.cloudfront.net/big-buck-bunny/master.m3u8')
hls.attachMedia(videoEl)
} else if (videoEl.canPlayType('application/vnd.apple.mpegurl')) {
videoEl.src = 'https://d2zihajmogu5jn.cloudfront.net/big-buck-bunny/master.m3u8'
}
}
}, [hlsVideoEl])

return (
<>
<h1>Video</h1>
<p>Useful testing for Replay handling video elements</p>
<div style={{ margin: 10 }}>
<h3>Video</h3>
<video controls={true} style={{ width: 500 }}>
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" />
<source src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" />
</video>
</div>

<div style={{ margin: 10 }}>
<h3>HLS Video</h3>
<video
ref={hlsVideoEl}
controls={true}
style={{ width: 500 }}
hls-src="https://d2zihajmogu5jn.cloudfront.net/big-buck-bunny/master.m3u8"
/>
</div>

<div style={{ margin: 10 }}>
<h3>Audio</h3>
<audio controls={true}>
Expand Down
Loading
Loading