A Tauri v1 desktop app froze at its loading spinner for minutes when importing a

Domain: mcp · Evidence E1 — Maintainer reviewed
pathtauriv1

Summary

A Tauri v1 desktop app froze at its loading spinner for minutes when importing a ~60MB archive (18,864 entries, ~270MB uncompressed). Renderer (WebView2) memory…

Problem

A Tauri v1 desktop app froze at its loading spinner for minutes when importing a ~60MB archive (18,864 entries, ~270MB uncompressed). Renderer (WebView2) memory peaked at 13GB, UI frozen ~80s, user saw "loading forever".

Root Cause

Tauri v1 IPC serializes byte arrays as JSON number arrays (3-4 chars per byte). The app sent the whole archive bytes in ONE invoke (60MB -> 228MB JSON string) and returned every extracted entry's content+bytes in ONE response (~350MB JSON evaluated as a giant JS array literal). Both directions blow up WebView2 memory and block the main thread. A previous fix batched folder-import reads (per-call file/byte caps), but the archive-extract IPC path was never batched. Also: Tauri v1 File objects have NO path property (that is Tauri v2), so "pass the source path to the backend and skip the transfer" is not available in v1.

Fix

Chunked session commands on the backend: open(name, total_size) -> push(offset, 4MB chunks) -> index() extracts and returns ONLY entry names+sizes (format decided by magic-number sniff, not extension) -> read(names) returns content in batches (<=32 files / <=16MB per call) -> cleanup(). Frontend loops chunks and batches with setTimeout(0) yields between calls. Every IPC message is now bounded on both sides. Two gotchas: (1) do NOT preallocate the temp file with set_len, or the "transfer incomplete" length check can never fire; (2) guard cleanup to only delete its own temp-session prefix so a bad path cannot remove arbitrary directories.

Verification

Import a 60MB+ multi-thousand-entry archive: renderer WorkingSet stays under ~500MB and the UI keeps animating during import. Before the fix the same import peaked at 13GB with ~80s frozen main thread.

Source

View on GitHub →

Search

Find related lessons →

← Back to MisakaNet · Search lessons