Fix some bugs & polish edge cases

This commit is contained in:
Vanilagy
2026-05-11 23:50:06 +02:00
parent d8c8606341
commit 81531cc510
8 changed files with 92 additions and 28 deletions
+1 -1
View File
@@ -1726,7 +1726,7 @@ const colorAlphaMergerWorkerCode = () => {
const format = alpha.format;
if (format === 'RGBA' || format === 'BGRA' || format === 'RGBX' || format === 'BGRX') {
// Pack alpha data tightly
// Pack alpha data tightly. Assume alpha is stored in RGB, so sample just from R for simplicity.
const rOffset = (format === 'RGBA' || format === 'RGBX') ? 0 : 2;
const pixelCount = width * height;
for (let i = 0; i < pixelCount; i++) {
+3 -2
View File
@@ -1245,8 +1245,9 @@ export class VideoSample implements Disposable {
? [this.squarePixelWidth, this.squarePixelHeight]
: [this.squarePixelHeight, this.squarePixelWidth];
if (options.crop) {
clampCropRectangle(options.crop, rotatedWidth, rotatedHeight);
let finalCrop = options.crop;
if (finalCrop) {
finalCrop = clampCropRectangle(finalCrop, rotatedWidth, rotatedHeight);
}
// These variables specify where the final sample will be drawn on the canvas
+7 -5
View File
@@ -591,11 +591,13 @@ const DEFAULT_RETRY_DELAY
// Check if this could be a CORS error. If so, we cannot recover from it and
// should not attempt to retry.
// CORS errors are intentionally not opaque, so we need to rely on heuristics.
const couldBeCorsError = error instanceof Error && (
error.message.includes('Failed to fetch') // Chrome
|| error.message.includes('Load failed') // Safari
|| error.message.includes('NetworkError when attempting to fetch resource') // Firefox
);
const couldBeCorsError = error instanceof Error
&& (
error.message.includes('Failed to fetch') // Chrome
|| error.message.includes('Load failed') // Safari
|| error.message.includes('NetworkError when attempting to fetch resource') // Firefox
)
&& typeof window !== 'undefined'; // CORS only happens in browser environments
if (couldBeCorsError) {
let originOfSrc: string | null = null;