Avoid opaque canvases in case of Firefox (fixes #117)

This commit is contained in:
Vanilagy
2025-09-16 17:42:23 +02:00
parent 530ccd7523
commit 1bb3c0e262
4 changed files with 44 additions and 9 deletions
+6 -2
View File
@@ -15,6 +15,7 @@ import {
toDataView,
toUint8Array,
SetRequired,
isFirefox,
} from './misc';
/**
@@ -228,7 +229,10 @@ export class VideoSample {
}
const canvas = new OffscreenCanvas(width, height);
const context = canvas.getContext('2d', { alpha: false, willReadFrequently: true });
const context = canvas.getContext('2d', {
alpha: isFirefox(), // Firefox has VideoFrame glitches with opaque canvases
willReadFrequently: true,
});
assert(context);
// Draw it to a canvas
@@ -343,7 +347,7 @@ export class VideoSample {
dest.set(this._data);
} else {
const canvas = this._data;
const context = canvas.getContext('2d', { alpha: false });
const context = canvas.getContext('2d');
assert(context);
const imageData = context.getImageData(0, 0, this.codedWidth, this.codedHeight);