mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Fix running = false being set too late for ReadOrchestrator workers (fixes #84)
This commit is contained in:
+2
-2
@@ -24,7 +24,7 @@
|
|||||||
chunked: true,
|
chunked: true,
|
||||||
chunkSize: 2**20
|
chunkSize: 2**20
|
||||||
});
|
});
|
||||||
const outputFormat = new Mediabunny.Mp4OutputFormat({});
|
const outputFormat = new Mediabunny.WavOutputFormat({});
|
||||||
|
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
button.textContent = 'Cancel';
|
button.textContent = 'Cancel';
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
video: () => ({
|
video: () => ({
|
||||||
codec: 'avc',
|
//codec: 'avc',
|
||||||
//fit: 'contain',
|
//fit: 'contain',
|
||||||
//frameRate: 27.123,
|
//frameRate: 27.123,
|
||||||
//width: 320,
|
//width: 320,
|
||||||
|
|||||||
+11
-3
@@ -178,6 +178,8 @@ export class BlobSource extends Source {
|
|||||||
this.onread?.(worker.currentPos, worker.currentPos + value.length);
|
this.onread?.(worker.currentPos, worker.currentPos + value.length);
|
||||||
this._orchestrator.supplyWorkerData(worker, value);
|
this._orchestrator.supplyWorkerData(worker, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
worker.running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,6 +411,7 @@ export class UrlSource extends Source {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
worker.running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,11 +421,14 @@ export class UrlSource extends Source {
|
|||||||
if (worker.currentPos >= worker.targetPos || worker.aborted) {
|
if (worker.currentPos >= worker.targetPos || worker.aborted) {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
|
|
||||||
|
worker.running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
worker.running = false;
|
||||||
|
|
||||||
// The previous UrlSource had logic for circumventing https://issues.chromium.org/issues/436025873; I haven't
|
// The previous UrlSource had logic for circumventing https://issues.chromium.org/issues/436025873; I haven't
|
||||||
// been able to observe this bug with the new UrlSource (maybe because we're using response streaming), so the
|
// been able to observe this bug with the new UrlSource (maybe because we're using response streaming), so the
|
||||||
// logic for that has vanished for now. Leaving a comment here if this becomes relevant again.
|
// logic for that has vanished for now. Leaving a comment here if this becomes relevant again.
|
||||||
@@ -681,6 +687,8 @@ export class StreamSource extends Source {
|
|||||||
throw new TypeError('options.read must return or resolve to a Uint8Array or a ReadableStream.');
|
throw new TypeError('options.read must return or resolve to a Uint8Array or a ReadableStream.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
worker.running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,6 +941,7 @@ class ReadOrchestrator {
|
|||||||
// another one so close to it
|
// another one so close to it
|
||||||
const gapTolerance = 2 ** 17;
|
const gapTolerance = 2 ** 17;
|
||||||
|
|
||||||
|
// This check also implies worker.currentPos <= outerHole.start, a critical condition
|
||||||
if (closedIntervalsOverlap(
|
if (closedIntervalsOverlap(
|
||||||
outerHole.start - gapTolerance, outerHole.start,
|
outerHole.start - gapTolerance, outerHole.start,
|
||||||
worker.currentPos, worker.targetPos,
|
worker.currentPos, worker.targetPos,
|
||||||
@@ -1024,15 +1033,14 @@ class ReadOrchestrator {
|
|||||||
|
|
||||||
void this.options.runWorker(worker)
|
void this.options.runWorker(worker)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
worker.running = false;
|
||||||
|
|
||||||
if (worker.pendingSlices.length > 0) {
|
if (worker.pendingSlices.length > 0) {
|
||||||
worker.pendingSlices.forEach(x => x.reject(error)); // Make sure to propagate any errors
|
worker.pendingSlices.forEach(x => x.reject(error)); // Make sure to propagate any errors
|
||||||
worker.pendingSlices.length = 0;
|
worker.pendingSlices.length = 0;
|
||||||
} else {
|
} else {
|
||||||
throw error; // So it doesn't get swallowed
|
throw error; // So it doesn't get swallowed
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
worker.running = false;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user