Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem/Bug]: 0x800704EC or 0x80004004 using CreateCoreWebView2EnvironmentWithOptions. #5192

Open
alexQuantum1 opened this issue Apr 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@alexQuantum1
Copy link

alexQuantum1 commented Apr 3, 2025

What happened?

Hi,

I don't know if it's the right place to ask this question, redirect me to the right place if needed :)

Context:
I'm using:

  • WebView2 1.0.2739.15
  • WindowsImplementationLibrary 1.0.240803.1
  • WebView2Runtime 131.0.2903.112 in it's "fixed version" and copied in C:/programdata. My program then use the options of CreateCoreWebView2EnvironmentWithOptions to specify the path.
  • Windows 10
  • Windows antivirus scan is parametered to run at startup
  • Some group policies are applied but none directly network or application related

Problem
Once every 100 to 300 runs I get a 0x800704EC or 0x80004004 from CreateCoreWebView2EnvironmentWithOptions().

void WebBrowser::InitializeWebView()
{
    CloseWebView();

    //This line could be uncommented if one day we went to use the webview2runtime from the system: e.g an update of edge seems to embed the runtime and it is natively contained under windows11
    //CString subFolder = GetInstallPath();
    CString subFolder = "C:\\ProgramData\\WebView2Runtime";
    CString appData = GetUserDataFolder();

    HRESULT hr = CreateCoreWebView2EnvironmentWithOptions(
        ConvertLPCSTRToPCWSTR(subFolder),
        ConvertLPCSTRToPCWSTR(appData),
        nullptr,
        Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
            this,
            &WebBrowser::OnCreateEnvironmentCompleted).Get());

    if (!SUCCEEDED(hr))
    {
        CString text;
        if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
        {
            text = L"Cannot found the WebView2 component.";
        }
        else
        {
            text = L"Cannot create the webview environment.";
        }

        ShowFailure(hr, text);
    }
}
HRESULT WebBrowser::OnCreateEnvironmentCompleted(
    HRESULT result,
    ICoreWebView2Environment* environment)
 {
    CHECK_FAILURE(result);

    if (!environment)
        return E_FAIL;

    CHECK_FAILURE(environment->QueryInterface(IID_PPV_ARGS(&m_pImpl->m_webViewEnvironment)));
    CHECK_FAILURE(environment->QueryInterface(IID_PPV_ARGS(&m_pImpl->m_webViewEnvironment2)));

    CHECK_FAILURE(m_pImpl->m_webViewEnvironment->CreateCoreWebView2Controller(
        m_hWnd,
        Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
            this,
            &WebBrowser::OnCreateWebViewControllerCompleted).Get()));

    return S_OK;
  }

HRESULT WebBrowser::OnCreateWebViewControllerCompleted(
    HRESULT result,
    ICoreWebView2Controller* controller)
{
    if (result == S_OK)
    {
        if (controller != nullptr)
        {
            m_pImpl->m_webController = controller;
            CHECK_FAILURE(controller->get_CoreWebView2(&m_pImpl->m_webView));

            if (!m_pImpl->m_webView)
                return E_FAIL;

            CHECK_FAILURE(m_pImpl->m_webView->QueryInterface(IID_PPV_ARGS(&m_pImpl->m_webView2)));
            CHECK_FAILURE(m_pImpl->m_webView->QueryInterface(IID_PPV_ARGS(&m_pImpl->m_webView2_16)));

            CHECK_FAILURE(m_pImpl->m_webView->get_Settings(&m_pImpl->m_webSettings));

            wil::com_ptr<ICoreWebView2Settings> settings;
            CHECK_FAILURE(m_pImpl->m_webView->get_Settings(&settings));
            if (settings)
            {
                settings->put_AreHostObjectsAllowed(TRUE); // Allows host object usage

                // Obtain ICoreWebView2Settings5
                wil::com_ptr<ICoreWebView2Settings5> settings5;
                HRESULT hr = settings->QueryInterface(IID_PPV_ARGS(&settings5));
                if (SUCCEEDED(hr) && settings5)
                {
                    // Deactivate Pinch and Zoom
                    settings5->put_IsPinchZoomEnabled(FALSE);
                }
                else
                {
                    // The settings interface ICoreWebView2Settings5 is not available
                    ShowFailure(hr, "ICoreWebView2Settings5 interface is not available.");
                }
            }

            RegisterEventHandlers();

            ResizeToClientArea();
        }

        auto callback = m_callbacks[CallbackType::CreationCompleted];
        if (callback != nullptr)
            RunAsync(callback);
    }
    else
    {
        ShowFailure(result, "Cannot create webview environment."); // HERE IS THE ISSUES
    }

    return S_OK;
}

The error ID seems to point at some Group Policies / Antivirus configuration that would block the proper initialisation.
Yet i've been unable so far to identify precisely what parameters or rules are involved and why the occurence is not systematic if these configurations are supposed to block the procesus.

At this point anything i try can only be a guess that would turn out to be true or false only after undreds to thousands of tests...

Thanks you for your time,
Alex.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

131.0.2903.112

SDK Version

1.0.2739.15

Framework

Other

Operating System

Windows 10

OS Version

19044.5487 (KB5051974)

Repro steps

The issue happens during initialisation once every 100 to 300 startup.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@alexQuantum1 alexQuantum1 added the bug Something isn't working label Apr 3, 2025
@alexQuantum1 alexQuantum1 changed the title [Problem/Bug]: 0x800704EC or 0x80004004 are sometimes returned by CreateCoreWebView2EnvironmentWithOptions. [Problem/Bug]: 0x800704EC or 0x80004004 using CreateCoreWebView2EnvironmentWithOptions. Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant