fix: probe WebView2 backend with the real user data folder#8
Open
kattapug wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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:createWebViewHandle()forwardsoptions.getWinWebView2BackendOptions().getUserDataFolder()toCreateCoreWebView2EnvironmentWithOptions(). 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. insideC:\Program Files\OpenStudio. That path is not writable by a normal user, environment creation fails withE_ACCESSDENIED, and the probe reports the backend as unavailable.The real
WebBrowserComponentwas 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)
GetAvailableCoreWebView2BrowserVersionString→S_OK,150.0.4078.83. Runtime is fine.Embedded browser backend supported: No.C:\Program Files\OpenStudio\OpenStudio.exe.WebView2gets created, log flips toEmbedded browser backend supported: Yes, frontend reachesboot-ready.Usersmodify on that folder makes non-elevated launches work too — confirming the failure is purely the probe's user data folder, not the runtime.Change
makeBrowserBackendProbeOptions()helper that addsWinWebView2().withUserDataFolder(getWebView2UserDataFolder())on Windows.buildStartupSelfTestReport(),buildStartupDiagnostics().MainComponentctor now reusesgetWebView2UserDataFolder()instead of repeating the path literal.Notes
determineStartupFailureCategory()'swebview2-backend-unusablebranch still can't say why. Logging theHRESULTwould have made this a one-minute diagnosis instead of a bisect, anddocs/runtime-dependency-contract.mdasks that branch to be actionable.🤖 Generated with Claude Code