Skip to content

web: model discovery, live download progress, VLM deadlock fix, RAG/vision download UI#510

Merged
Siddhesh2377 merged 1 commit into
v2-sdk-testing-fixesfrom
web-rag-discovery-download-fixes
Jun 22, 2026
Merged

web: model discovery, live download progress, VLM deadlock fix, RAG/vision download UI#510
Siddhesh2377 merged 1 commit into
v2-sdk-testing-fixesfrom
web-rag-discovery-download-fixes

Conversation

@Siddhesh2377

@Siddhesh2377 Siddhesh2377 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Web SDK testing-pass fixes found while exercising the example app end-to-end.

Model discovery (was: every downloaded model showed "Download" after reload)

  • WASM exports: added _rac_inference_framework_from_proto + _rac_framework_raw_value to RAC_EXPORTED_FUNCTIONS_BASE. Without them frameworkOPFSDir() returned null and hydrateModelRegistry() skipped every model, so OPFS-backed models never re-detected on cold start.
  • UI refresh: the example never subscribed to the SDK models.hydrated event, so the picker/Storage/Docs views never re-queried after the async cold-start hydrate. model-selection.ts now subscribes once and refreshes consumers.

Download progress (was: UI froze at 0% until 100%)

  • Implemented the async http_download platform-adapter slot in PlatformAdapter.ts (streaming fetch + ReadableStream → MEMFS, per-chunk progress, resume via Range, cancel via AbortController, 416-on-resume treated as complete).
  • Added an Emscripten-only event-driven download driver in download_orchestrator.cpp that uses the slot when present (native path unchanged: #ifdef __EMSCRIPTEN__ + slot-null fallback).

VLM inference (was: hung forever in the image encode)

  • Root cause: the synchronous main-thread VLM encode requested 8 ggml threads but PTHREAD_POOL_SIZE=4, so on-demand worker spawn deadlocked the blocked main thread. Bumped PTHREAD_POOL_SIZE to 8 (covers the engine's capped max). VLM now completes.

RAG + Vision UI

  • Documents view: added Download buttons next to the embedding/LLM pickers (live %, reflects downloaded state).
  • Vision view: added a "Load image…" button to analyze a file from disk (not just the camera).

ONNX/sherpa WASM vendoring

  • Ported the prebuilt-download-first vendor scripts (pull the matched ORT+sherpa WASM archives from the sherpa-onnx-rac release) instead of the slow from-source-only path.

Known follow-ups (not in this PR)

  • ONNX backend instantiation on the local build (large-module wasmTable export under emcc 5.0.0) — under investigation; blocks RAG embeddings + speech end-to-end.
  • VLM runs synchronously on the main thread (10–20s UI freeze) — worker-offload is scaffolded (OffscreenRuntimeBridge) but not wired.

Note

Medium Risk
Touches core download orchestration and platform I/O on Emscripten (behavior change for all Web model downloads); WASM link/export and pthread sizing affect VLM builds. Example-only UI changes are low risk.

Overview
End-to-end fixes for the Web SDK and RunAnywhereAI example after full-app testing.

Model discovery after reload exports _rac_inference_framework_from_proto and _rac_framework_raw_value so JS can resolve framework OPFS folders for hydrateModelRegistry(). The example subscribes once to models.hydrated in model-selection.ts so the picker and toolbar refresh when async cold-start hydration marks models as on disk.

Download UX wires the platform http_download slot in PlatformAdapter.ts (streaming fetch → MEMFS, live progress, Range resume, abort/cancel, HTTP 416 treated as complete). On Emscripten, download_orchestrator.cpp uses a new event-driven driver when that slot exists; the blocking sync worker remains the fallback. Web streaming skips per-byte SHA-256 but keeps size validation and HTTPS.

VLM raises PTHREAD_POOL_SIZE from 4 to 8 so ggml compute threads do not deadlock the main thread during synchronous encode.

Example UI: Documents gets per-picker Download buttons with % status; Vision adds Load image… (RGB decode + analyze without the camera). ONNX/sherpa vendor scripts prefer prebuilt WASM tarballs from sherpa-onnx-rac, with from-source fallback.

Reviewed by Cursor Bugbot for commit 2bbba92. Configure here.

… refresh), live download progress via async http_download slot, VLM pthread-pool deadlock, RAG + vision download UI, prebuilt ONNX/sherpa WASM vendoring
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 561a81b5-7983-47e0-b044-0b96ffaff54c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch web-rag-discovery-download-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Docs buttons miss hydrate refresh
    • Subscribed the Documents tab to shared model state changes and refreshes the download buttons on activation so hydration updates are reflected.

Create PR

Or push these changes by commenting:

@cursor push a41097fbdf
Preview (a41097fbdf)
diff --git a/examples/web/RunAnywhereAI/src/views/documents.ts b/examples/web/RunAnywhereAI/src/views/documents.ts
--- a/examples/web/RunAnywhereAI/src/views/documents.ts
+++ b/examples/web/RunAnywhereAI/src/views/documents.ts
@@ -23,6 +23,7 @@
   type RAGDocumentSummary,
   type RAGSearchResult,
 } from '@runanywhere/web';
+import { onModelStateChange } from '../components/model-selection';
 import { escapeHtml } from '../services/escape-html';
 import { formatError } from '../services/format-error';
 
@@ -37,6 +38,7 @@
 let selectedLlmModelId = '';
 /** Model-id pair the current native pipeline was created with. */
 let createdPipelineKey: string | null = null;
+let unsubscribeState: (() => void) | null = null;
 
 // ---------------------------------------------------------------------------
 // Init
@@ -114,8 +116,14 @@
     void downloadSelectedModel(selectedLlmModelId, 'LLM');
   });
   refreshModelButtons();
+  unsubscribeState?.();
+  unsubscribeState = onModelStateChange(() => refreshModelButtons());
 
-  return {};
+  return {
+    onActivate: () => {
+      refreshModelButtons();
+    },
+  };
 }
 
 // ---------------------------------------------------------------------------

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2bbba92. Configure here.

container.querySelector('#docs-llm-download-btn')!.addEventListener('click', () => {
void downloadSelectedModel(selectedLlmModelId, 'LLM');
});
refreshModelButtons();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Docs buttons miss hydrate refresh

Medium Severity

The Documents tab’s new embedding/LLM download controls call refreshModelButtons() only at init. They don’t listen for models.hydrated or onModelStateChange, unlike Vision/Chat. After async OPFS hydration marks models downloaded, the buttons can stay enabled as “Download” until the user changes a picker.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2bbba92. Configure here.

@Siddhesh2377 Siddhesh2377 merged commit 2bbba92 into v2-sdk-testing-fixes Jun 22, 2026
6 checks passed
@Siddhesh2377 Siddhesh2377 deleted the web-rag-discovery-download-fixes branch June 22, 2026 06: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.

1 participant