Skip to content

Fix OpenCV tracker hang: handle Promise-based WASM export and add timeout - #2

Merged
veillette merged 1 commit into
mainfrom
claude/fix-opencv-tracker-hang-tISsY
Feb 18, 2026
Merged

Fix OpenCV tracker hang: handle Promise-based WASM export and add timeout#2
veillette merged 1 commit into
mainfrom
claude/fix-opencv-tracker-hang-tISsY

Conversation

@veillette

Copy link
Copy Markdown
Collaborator

The @techstark/opencv-js package (v4.12.0+) can export its default as a
Promise. The previous loadCV() did not handle this case — it set
onRuntimeInitialized on the Promise object itself, which never fires,
causing the tracker to hang indefinitely.

  • Await the default export when it is a Promise
  • Add a 30 s timeout on WASM initialisation so it rejects instead of
    hanging forever
  • Clear the cached promise on failure so retries are possible
  • Attach .catch() to the fire-and-forget initFromVideo() call so
    failures surface in the console and re-show the hint text
  • Wrap Mat operations in try/finally to prevent WASM memory leaks if
    OpenCV throws mid-operation

https://claude.ai/code/session_014aYixwNeB8Fx1jWz9AyXUD

…eout

The @techstark/opencv-js package (v4.12.0+) can export its default as a
Promise. The previous loadCV() did not handle this case — it set
onRuntimeInitialized on the Promise object itself, which never fires,
causing the tracker to hang indefinitely.

- Await the default export when it is a Promise
- Add a 30 s timeout on WASM initialisation so it rejects instead of
  hanging forever
- Clear the cached promise on failure so retries are possible
- Attach .catch() to the fire-and-forget initFromVideo() call so
  failures surface in the console and re-show the hint text
- Wrap Mat operations in try/finally to prevent WASM memory leaks if
  OpenCV throws mid-operation

https://claude.ai/code/session_014aYixwNeB8Fx1jWz9AyXUD
@veillette
veillette merged commit 0151499 into main Feb 18, 2026
1 check passed
@veillette
veillette deleted the claude/fix-opencv-tracker-hang-tISsY branch February 18, 2026 00:16
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.

2 participants