Skip to content

When a promise failed, the whole queue was ruined#1826

Merged
jpggvilaca merged 9 commits into
mainfrom
jvilaca/sam-issues
May 12, 2026
Merged

When a promise failed, the whole queue was ruined#1826
jpggvilaca merged 9 commits into
mainfrom
jvilaca/sam-issues

Conversation

@jpggvilaca
Copy link
Copy Markdown
Contributor

@jpggvilaca jpggvilaca commented May 11, 2026

📝 Description

Issues addressed:

  • Browser (Chrome): intermittent JSEP Resize kernel failures → WASM heap corruption → every subsequent ortSession.run() returns garbage.
  • Tauri (WebView2 / WKWebView): ortSession.run() occasionally hangs forever (WebGPU / memory related). The serial runQueue chained every later call onto the never-settling promise, blocking the session indefinitely.
  • Random issue we had before on chrome that the worker was forever loading (dont await for cache.put)
  • Cleanup/simplification

Manually tested Geti Tune browser and tauri app (by updating the hash of the packages that 'tiged' uses)

✨ Type of Change

Select the type of change your PR introduces:

  • 🐞 Bug fix – Non-breaking change which fixes an issue
  • 🚀 New feature – Non-breaking change which adds functionality
  • 🔨 Refactor – Non-breaking change which refactors the code base
  • 💥 Breaking change – Changes that break existing functionality
  • 📚 Documentation update
  • 🔒 Security update
  • 🧪 Tests

🧪 Testing Scenarios

Describe how the changes were tested and how reviewers can test them too:

  • ✅ Tested manually
  • 🤖 Run automated end-to-end tests

✅ Checklist

Before submitting the PR, ensure the following:

  • 🔍 PR title is clear and meaningful
  • ✍️ PR description clearly explains the changes and their reason
  • 📝 I have linked the PR to the corresponding GitHub Issues, if any
  • 💬 I have commented my code, especially in hard-to-understand areas
  • 📄 I have made corresponding changes to the documentation
  • ✅ I have added tests that prove my fix is effective or my feature works

Copilot AI review requested due to automatic review settings May 11, 2026 11:11
@jpggvilaca jpggvilaca added the UI label May 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the smart-tools Web inference pipeline against browser/WebView pathologies where onnxruntime-web runs can hang indefinitely or leave the WASM heap corrupted, and where cache writes can stall model loading.

Changes:

  • Make model caching best-effort (fire-and-forget cache.put) so model loads aren’t blocked by slow/blocked Cache API writes.
  • Add session “poisoning” semantics, optional per-run timeouts, and a reset() path to recreate the underlying InferenceSession from cached model bytes.
  • Refactor the serial run queue implementation to avoid propagating prior failures through the queue chain.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
web_ui/packages/smart-tools/src/utils/tool-utils.ts Makes caching non-blocking by not awaiting cache.put() and swallowing cache errors.
web_ui/packages/smart-tools/src/segment-anything/session.ts Adds timeout/poison/reset mechanics and refactors the serialized run() queue implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web_ui/packages/smart-tools/src/segment-anything/session.ts Outdated
Comment thread web_ui/packages/smart-tools/src/segment-anything/session.ts
Comment thread web_ui/packages/smart-tools/src/segment-anything/segment-anything.ts Outdated
Copy link
Copy Markdown
Contributor

@dwesolow dwesolow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested those changes in tauri, works fine.
Thanks!

@jpggvilaca jpggvilaca added this pull request to the merge queue May 12, 2026
Merged via the queue into main with commit c8c0277 May 12, 2026
28 checks passed
@jpggvilaca jpggvilaca deleted the jvilaca/sam-issues branch May 12, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants