From 226b260319fd6784942720dd322d81600b784b39 Mon Sep 17 00:00:00 2001 From: S1m <31284753+p1gp1g@users.noreply.github.com> Date: Fri, 13 Feb 2026 13:44:11 +0100 Subject: [PATCH] Fix videos on Firefox (#32497) * Fix videos on Firefox Videos are using cross-origin requests, and Firefox blocks them before passing to the service worker if the element doesn't have the crossorigin attribute to give CORS support * React needs camelCase attr names --------- Co-authored-by: David Baker --- src/components/views/messages/MVideoBody.tsx | 4 ++++ .../views/messages/__snapshots__/MVideoBody-test.tsx.snap | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/components/views/messages/MVideoBody.tsx b/src/components/views/messages/MVideoBody.tsx index 680704d6fd..fff03d0dca 100644 --- a/src/components/views/messages/MVideoBody.tsx +++ b/src/components/views/messages/MVideoBody.tsx @@ -326,6 +326,10 @@ class MVideoBodyInner extends React.PureComponent { // Disable downloading as it doesn't work with e2ee video, // users should use the dedicated Download button in the Message Action Bar controlsList="nodownload" + // The video uses a cross-origin request. + // Firefox explicitly bypasses services workers for crossorigin + // video elements without crossorigin attribute. + crossOrigin="anonymous" preload={preload} muted={autoplay} autoPlay={autoplay} diff --git a/test/unit-tests/components/views/messages/__snapshots__/MVideoBody-test.tsx.snap b/test/unit-tests/components/views/messages/__snapshots__/MVideoBody-test.tsx.snap index adb6974d72..d4c0215990 100644 --- a/test/unit-tests/components/views/messages/__snapshots__/MVideoBody-test.tsx.snap +++ b/test/unit-tests/components/views/messages/__snapshots__/MVideoBody-test.tsx.snap @@ -13,6 +13,7 @@ exports[`MVideoBody does not crash when given portrait dimensions 1`] = ` class="mx_MVideoBody" controls="" controlslist="nodownload" + crossorigin="anonymous" poster="data:image/png;base64,00" preload="none" /> @@ -37,6 +38,7 @@ exports[`MVideoBody should show poster for encrypted media before downloading it class="mx_MVideoBody" controls="" controlslist="nodownload" + crossorigin="anonymous" poster="https://server/_matrix/media/v3/download/server/encrypted-poster" preload="none" title="alt for a test video" @@ -62,6 +64,7 @@ exports[`MVideoBody with video previews/thumbnails disabled should download vide class="mx_MVideoBody" controls="" controlslist="nodownload" + crossorigin="anonymous" poster="https://server/_matrix/media/v3/download/server/encrypted-poster" preload="none" title="alt for a test video"