Skip to content

Fix transcription failure after Windows screen lock (#39) - #41

Merged
wassgha merged 2 commits into
mainfrom
cursor/webgpu-screen-lock-fallback-c3c1
Jul 30, 2026
Merged

wassgha merged 2 commits into
mainfrom
cursor/webgpu-screen-lock-fallback-c3c1

Conversation

@wassgha

@wassgha wassgha commented Jul 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #39: when transcription is running on WebGPU and Windows locks the screen, Chromium tears down the GPU instance. ONNX Runtime then fails with Failed to download data from buffer / A valid external Instance reference no longer exists, and the job aborts.

This change detects that class of WebGPU device-loss errors mid-transcription, reloads Whisper on WASM, and retries the current speech segment so the run can finish instead of surfacing a raw OrtRun error.

Changes

  • Add isWebGpuDeviceLostError() (lib/webgpu.ts) matching the OrtRun / mapAsync failure from the issue
  • Keep getAsr() close to its original shape; track forceWasm / asrDevice for fallback
  • On device loss during a segment: roll back streamed partial text, show “GPU interrupted — continuing on CPU…”, retry once on WASM
  • Friendlier error copy if recovery somehow still fails
  • Unit coverage in scripts/webgpu-test.ts

Test plan

  • npx tsx scripts/webgpu-test.ts
  • eslint on touched files
  • tsc --noEmit
  • Manual (Windows desktop): start transcription on WebGPU, lock the screen mid-run, unlock — expect progress to continue on CPU rather than the red OrtRun buffer error
Open in Web Open in Cursor 

cursoragent and others added 2 commits July 30, 2026 06:41
WebGPU OrtRun fails with "Failed to download data from buffer" when the
GPU instance is torn down (common on Windows lock). Detect that class of
errors and continue the current speech segment on WASM instead of aborting.

Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
Keep getAsr close to the original shape, and express mid-run GPU loss as a
single try/catch retry around each speech slice instead of nested attempt loops.

Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
@wassgha
wassgha marked this pull request as ready for review July 30, 2026 06:52
@wassgha
wassgha merged commit 68d1597 into main Jul 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failure to download data from buffer after screen locks (Desktop App, Windows 10)

2 participants