wavespeed-desktop icon indicating copy to clipboard operation
wavespeed-desktop copied to clipboard

Renderer freezes after a few hours: wavespeed_prediction_inputs grows to ~80 MB and is rewritten in full on every completed prediction

Open eashwar83 opened this issue 1 month ago • 0 comments

Environment

  • WaveSpeed Desktop 2.1.76 (Electron 43.6.0, Chrome 150), also seen on 2.1.37
  • Windows 11 Home 26200, 16 GB RAM
  • Snapdragon X Elite (ARM64) running the win-x64 build under emulation (no ARM64 build is published)

Symptom

After a few hours of Playground use the UI stops responding completely: no clicks, no typing, no scrolling. The native title-bar buttons (minimize, maximize, close) still work and the app shuts down cleanly when closed, so the main process is fine; it is the renderer that hangs. logs/main.log shows nothing at the time of the freeze. The only way to recover is to quit and relaunch.

Windows Error Reporting logged RADAR_PRE_LEAK_64 (Resource Exhaustion Detector) against WaveSpeed Desktop.exe twice in three days, so the renderer is also the top memory consumer when the system runs low.

Cause

The prediction-inputs store (src/renderer/.../predictionInputsStore, in the built bundle: STORAGE_KEY = "wavespeed_prediction_inputs", MAX_ENTRIES = 1e4) keeps one entry per prediction in a single localStorage key and re-serializes the whole list on every save:

function saveToStorage(entries) {
  const array = Array.from(entries.values())
    .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
    .slice(0, MAX_ENTRIES);
  localStorage.setItem(STORAGE_KEY, JSON.stringify(array));
}

save is called from PlaygroundPage each time a prediction (or each batch result) finishes. The entries keep the full inputs object, including reference_images / images values, and those can be data:image/...;base64 strings.

On my machine the key reached the 10,000-entry cap after about two months:

entries 10,000 (oldest 2026-08-09)
serialized length 40.7 M chars = 81 MB as UTF-16 in LevelDB
inputs.prompt 20 MB
inputs.reference_images[] 12 MB (73 base64 data URLs, largest 473 KB each)
inputs.images[] 6.6 MB

So once the cap is reached every finished generation does, on the renderer main thread:

  1. JSON.stringify of 40 M characters
  2. a synchronous localStorage.setItem that copies the 81 MB value to the browser process
  3. an 81 MB append to Local Storage/leveldb/*.log on disk (I measured a single 77 MB log file written in the first four minutes after launch)

Over a session of a few hundred generations that is tens of GB of serialization and disk writes plus the garbage it leaves behind, and the renderer eventually stops responding. MAX_ENTRIES bounds the count but not the bytes, and ARCHIVE_AGE_DAYS = 7 only filters what getArchived() returns; nothing ever evicts old entries from storage.

Workaround

Open DevTools (F12) in the app, run localStorage.removeItem('wavespeed_prediction_inputs'), then restart the app (the restart matters: otherwise the in-memory Map is written back on the next save). The app has been stable since.

Suggested fix

Any of these would remove the cliff:

  • Move the store to IndexedDB (or the main process's renderer-state.json / SQLite) with per-entry writes instead of one monolithic value.
  • If it has to stay in localStorage, store only URLs and strip data: URIs from inputs before saving, cap by bytes (e.g. a few MB) as well as by count, and actually delete entries older than ARCHIVE_AGE_DAYS instead of only hiding them.
  • Debounce saveToStorage and/or write it from a web worker so a save never blocks the UI thread.

A "Clear prediction input history" button in Settings would also give users a way out without DevTools.

Happy to test a build.

eashwar83 avatar Oct 11 '26 15:10 eashwar83