Skip to content

fix(windows): surface the failing HRESULT on webview creation failure - #14

Merged
Y-PLONI merged 3 commits into
Otzaria:masterfrom
palmoni5:fix/windows-creation-failure-hresult
Aug 28, 2026
Merged

fix(windows): surface the failing HRESULT on webview creation failure#14
Y-PLONI merged 3 commits into
Otzaria:masterfrom
palmoni5:fix/windows-creation-failure-hresult

Conversation

@palmoni5

Copy link
Copy Markdown
Member

Problem

In release builds debugLog is compiled out (#ifndef NDEBUG), so when createInAppWebView fails the host only ever sees:

PlatformException(0, Cannot create the InAppWebView instance!, null, null)

The actual HRESULT — already checked by failedAndLog inside InAppWebView::createInAppWebViewEnv — is discarded. A recent field investigation (plugins failing to load on a Windows-on-ARM machine, where the app runs x64 under emulation and the composition-controller path is refused) needed several rounds of remote diagnostics that a single HRESULT would have answered immediately.

Changes

  • createInAppWebViewEnv passes the failing HRESULT to its completion handler; the visible, headless and in-app-browser callers all append it to the error they return.
  • getHRErrorString in log.h reports the hex code next to the system message, because the message text is localized and often generic.
  • Hang fix: a synchronous failure of CreateCoreWebView2Controller / CreateCoreWebView2CompositionController never invoked the callback, so the MethodResult was never completed and the Dart caller waited forever. Both paths now report it. This also removed the duplicated callback bodies between the ControllerOptions and legacy branches.
  • WindowsWebViewCreationFailures broadcasts creation failures to the host. Creation fails before any webview object exists, so there is no per-widget callback to hang this on — until now the only symptom was a blank area plus an unhandled async error, with no way for the host to render its own message.

Verification

  • flutter test passes in flutter_inappwebview_windows (the native-source assertions in native_creation_failure_cleanup_test.dart were updated, and a new test covers the failure broadcast).
  • flutter build windows of the consuming app (Otzaria) compiles the changed native code.

Context: Otzaria/otzaria#1016, Otzaria/otzaria#1014.

createInAppWebViewEnv now passes the failing HRESULT to its completion handler, and all three callers append it to the error returned to Dart. In release builds debugLog is compiled out, so a creation failure reached the host as a bare "Cannot create the InAppWebView instance!" with no way to tell an access denial from an unsupported composition path.

getHRErrorString reports the hex code alongside the system message, since the message text is localized and often generic.

This also fixes a hang: a synchronous failure of CreateCoreWebView2Controller / CreateCoreWebView2CompositionController never invoked the callback, so the MethodResult was never completed and the Dart caller waited forever.

WindowsWebViewCreationFailures broadcasts the failure to the host application. Creation fails before any webview object exists, so there is no callback to hang this on, and the only symptom was a blank area plus an unhandled async error.
The default 5s DISCOVERY_TIMEOUT killed --gtest_list_tests mid-print on a cold CI runner, failing the build before any test ran.
@palmoni5
palmoni5 force-pushed the fix/windows-creation-failure-hresult branch from 764b5f3 to 7bdd355 Compare August 27, 2026 22:26
@Y-PLONI
Y-PLONI merged commit 5a70b01 into Otzaria:master Aug 28, 2026
1 check passed
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.

2 participants