[URGENT/CRITICAL] 100% Reproducible: Permanent Project Corruption and VFS Deadlock when toggling Web Worker in App Builder
1. Summary
A critical architectural flaw exists in the AI Studio App Builder preview runner. Switching an app’s implementation between “Main Thread” and “Web Worker” mode (involving worker.js) causes the preview sandbox to enter a permanent, unrecoverable “Broken State.” Once the error “Failed to load the app. Try reloading it.” is triggered, it becomes a terminal state. There is NO workaround or recovery path available to the user. Neither manual reloads, browser hard refreshes, clearing cache, nor clicking the project restart button can restore functionality. The affected Project ID is rendered permanently unusable, effectively resulting in the total loss of the project and all associated development progress.
This is a major blocker for performance-critical projects, such as Markdown-to-PDF generators, where offloading heavy PDF serialization to a Web Worker is a standard architectural requirement to prevent UI freezing.
2. Environment
-
Platform: Google AI Studio (Web Interface)
-
Feature: App Builder (Preview Pane)
-
Model: Gemini 3 Pro
-
Build Tool: Integrated Vite-based Sandbox
-
Reproducibility: 100% (Tested across multiple independent sessions)
-
Persistence: Fatal/Terminal. The corruption persists at the backend/session level.
3. Steps to Reproduce
-
Scenario A (Non-Worker to Worker):
-
Start a project (e.g., a Markdown-to-PDF tool) on the Main Thread.
-
Once the preview is active, ask the AI to refactor the generation logic into a Web Worker (
worker.js). -
Result: The sandbox fails to resolve the path, and the preview pane crashes.
-
-
Scenario B (Worker to Non-Worker - The Fatal Path):
-
Start a new project explicitly requesting a Web Worker architecture from the first prompt.
-
Once the app is running, ask the AI to switch back to Main Thread mode (removing the worker).
-
Result: The preview pane immediately crashes with “Failed to load the app.”
-
-
Verification of Terminal State (The “Point of No Return”):
-
Click the “Reload” button in the preview pane: Persistent Failure.
-
Hard refresh the browser tab (Ctrl+F5) or clear site data: Persistent Failure.
-
Exit AI Studio and re-enter the project: Persistent Failure.
-
Once this state is reached, the project is dead; the only option is to delete it.
-
4. Expected Behavior
-
The sandbox should handle hot-reloading and VFS re-mapping for Worker scripts seamlessly.
-
Architectural changes involving threading should be reversible without corrupting the project’s persistent state or session metadata.
5. Actual Result
-
Permanent Project Corruption: The Project ID enters a terminal error state that persists regardless of user intervention.
-
Vite Path Resolution Failure: The internal Vite system cannot resolve
worker.jspaths during transitions, leading to 404s or invalid URL errors even when files exist in the editor. -
VFS Lockup: The preview runner appears to be unable to clear the previous “Worker Thread” state, causing the boot sequence to hang indefinitely.
6. Technical Analysis (Hypothesis)
-
Project-Level Metadata Deadlock: The bug likely resides in how the App Builder’s backend tracks the entry points of a project. When a worker is added/removed, the manifest desynchronizes, but the “Failed” state is cached or written to the project’s database.
-
Service Worker / VFS Collision: The Service Worker orchestrating the sandbox environment maintains a stale reference to a non-existent
worker.jsblob, which interrupts the main thread’s boot process every time the project is opened. -
Unrecoverable Session State: Because the project “remembers” its last broken state, and there is no way to “Force Rebuild” or “Clean Cache” within AI Studio, the project remains in a boot-loop.
7. Evidence
-
UI Error Message: “Failed to load the app. Try reloading it.” (Permanent Overlay)
-
Recovery Success Rate: 0% (Tested with all standard browser and UI recovery techniques).
-
Use Case Failure: Standard frontend optimization (Multi-threading) is a “dangerous” operation that can lead to irreversible data loss.
8. Suggested Priority
URGENT/BLOCKER. This is a project-loss bug. It discourages advanced development and makes iterative architectural changes impossible. Any attempt to use Web Workers in the current App Builder environment is high-risk.
