mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-28 04:46:07 -08:00
perf(subsync): run alignment in a worker thread
Alignment and candidate scoring take up to ~1s per call on long media and an auto run makes several, which stalled mpv IPC and the overlay on the main process. They now run in a reusable worker (src/subsync/align-worker.ts) that idles out after 30s and falls back to the main thread if it cannot start. Aborting a run terminates the worker, so cancellation no longer waits for an in-flight alignment.
This commit is contained in:
8 files changed
+379
-75
No files matched your search
@@ -38,14 +38,6 @@ export const JELLYFIN_SUBTITLE_FETCH_TIMEOUT_MS = 15_000;
|
||||
|
||||
const COMMAND_OUTPUT_SUMMARY_CHARS = 300;
|
||||
|
||||
// Alignment and candidate scoring are synchronous CPU work (100ms to 1s each on long media).
|
||||
// Yield between them so mpv IPC, the overlay, and other main-process work keep flowing.
|
||||
// Also the cancellation point between those stages.
|
||||
export async function yieldToEventLoop(signal?: AbortSignal): Promise<void> {
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
signal?.throwIfAborted();
|
||||
}
|
||||
|
||||
// Keep the tail of tool output (errors come last; alass prints progress first) and strip
|
||||
// stream tokens: ffmpeg echoes input URLs, and Jellyfin URLs carry ApiKey.
|
||||
function summarizeCommandOutput(text: string): string {
|
||||
|
||||
Reference in new issue
Block a user