MicrosoftEdge / MicrosoftEdge/WebView2Feedback

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

Open
#5,192 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at WebBrowser::InitializeWebView and the call to CreateCoreWebView2EnvironmentWithOptions, then follow OnCreateEnvironmentCompleted and OnCreateWebViewControllerCompleted. Reproduce the intermittent startup failure with the fixed runtime path and record when 0x800704EC or 0x80004004 occurs; done means identifying the triggering configuration or a documented cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.