Skip to content

fix: probe WebView2 backend with the real user data folder#8

Open
kattapug wants to merge 1 commit into
sdevil7th:mainfrom
kattapug:fix/webview2-backend-probe-user-data-folder
Open

fix: probe WebView2 backend with the real user data folder#8
kattapug wants to merge 1 commit into
sdevil7th:mainfrom
kattapug:fix/webview2-backend-probe-user-data-folder

Conversation

@kattapug

Copy link
Copy Markdown

Problem

An installed Windows build (Inno installer, C:\Program Files\OpenStudio) shows the "Embedded browser backend unavailable" error screen for a normal (non-elevated) user, even though the WebView2 runtime is present and healthy.

Startup log:

Browser backend: webview2
Embedded browser backend supported: No
Detected WebView2 runtime version: 150.0.4078.83
VC++ Redistributable installed: Yes
Embedded browser backend is not available. Falling back to an error screen.

Root cause

On Windows, juce::WebBrowserComponent::areOptionsSupported() (JUCE 8.0.0, juce_WebBrowserComponent_windows.cpp) is not a compile-time capability check — it really constructs a WebView2 environment:

if (auto webView = WebBrowserComponent::Impl::Platform::WebView2::createWebViewHandle (options))
    return true;

createWebViewHandle() forwards options.getWinWebView2BackendOptions().getUserDataFolder() to CreateCoreWebView2EnvironmentWithOptions(). The three startup probes passed only .withBackend(...), so the folder was empty and WebView2 fell back to its default: <exe dir>\OpenStudio.exe.WebView2, i.e. inside C:\Program Files\OpenStudio. That path is not writable by a normal user, environment creation fails with E_ACCESSDENIED, and the probe reports the backend as unavailable.

The real WebBrowserComponent was already correct — it points at %APPDATA%\OpenStudio\WebView2UserData. Only the diagnostics probes were wrong, so the app blocked itself on a backend it could actually have used.

Evidence (Windows 11, WebView2 runtime 150.0.4078.83)

  • Loader/runtime probed directly out-of-process: GetAvailableCoreWebView2BrowserVersionStringS_OK, 150.0.4078.83. Runtime is fine.
  • Normal launch → Embedded browser backend supported: No.
  • Same binary launched elevated → C:\Program Files\OpenStudio\OpenStudio.exe.WebView2 gets created, log flips to Embedded browser backend supported: Yes, frontend reaches boot-ready.
  • Granting Users modify on that folder makes non-elevated launches work too — confirming the failure is purely the probe's user data folder, not the runtime.

Change

  • New makeBrowserBackendProbeOptions() helper that adds WinWebView2().withUserDataFolder(getWebView2UserDataFolder()) on Windows.
  • Used by all three probes: constructor diagnostics, buildStartupSelfTestReport(), buildStartupDiagnostics().
  • MainComponent ctor now reuses getWebView2UserDataFolder() instead of repeating the path literal.

Notes

  • Not compiled locally (no MSVC toolchain set up here) — relies on CI. Change is small and mechanical; the diagnosis itself was verified against the shipped 1.x installer as described above.
  • Follow-up worth doing separately: determineStartupFailureCategory()'s webview2-backend-unusable branch still can't say why. Logging the HRESULT would have made this a one-minute diagnosis instead of a bisect, and docs/runtime-dependency-contract.md asks that branch to be actionable.

🤖 Generated with Claude Code

On Windows, juce::WebBrowserComponent::areOptionsSupported() is not a
compile-time capability check: it calls createWebViewHandle(), which in turn
calls CreateCoreWebView2EnvironmentWithOptions() with the user data folder
taken from the supplied options.

The startup probes passed Options().withBackend(webview2) with no
WinWebView2 options, so WebView2 fell back to its default user data folder
of "<exe dir>\OpenStudio.exe.WebView2". For an installed build that is
C:\Program Files\OpenStudio, which is not writable by a normal user, so
environment creation failed with E_ACCESSDENIED and the probe reported the
backend as unavailable. The app then showed the "Embedded browser backend
unavailable" screen even though the WebView2 runtime was installed and
working, and even though the real WebBrowserComponent already points at a
writable user data folder under AppData.

Add makeBrowserBackendProbeOptions() and use it for all three probes
(constructor diagnostics, buildStartupSelfTestReport, buildStartupDiagnostics)
so they exercise the same user data folder the real component uses. Also
reuse getWebView2UserDataFolder() in the component options instead of
repeating the path literal.

Verified on Windows 11 with WebView2 runtime 150.0.4078.83: the installed
build logged "Embedded browser backend supported: No" for a normal user and
"Yes" when run elevated (which made the Program Files folder writable),
matching the E_ACCESSDENIED path fixed here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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