Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

HelloWebView contains race condition

Open
#228 2 comments 0 reactions 1 assignee View on GitHub

@pieths-ms is already working on this.

Since Dec 11, 2023.

Assessment

This issue has not been assessed yet.

Description

I based my usage of WebView2 on the HelloWebView.cpp sample, however, a recent windows update (sometime on or before Decmber 11, 2023) broke our application because the startup scripts are no longer executed. We fixed the issue by moving the calls to AddScriptToExecuteOnDocumentCreated to occur before calling Navigate. I recommend updating the samples to do the same (such as https://github.com/MicrosoftEdge/WebView2Samples/blob/85e53c9dc4245ed74fc737554640644d4b0f3bb5/GettingStartedGuides/Win32_GettingStarted/HelloWebView.cpp).

I've investigated a bit more and determined this race condition seems to always occur if you are navigating to a local file URL, i.e.

webview->AddScriptToExecuteOnDocumentCreated(L"console.log('A')", nullptr);
webview->Navigate(L"file:///C:/temp/testpage.html");
webview->AddScriptToExecuteOnDocumentCreated(L"console.log('B')", nullptr);

In that example the first console log will show up, but not the second. If you modify the example to go to an HTTP URL, both will show up.

Dominant language
C++
Stars
1k
Forks
521
Avg merge
13m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from MicrosoftEdge/WebView2Samples

All issues in MicrosoftEdge/WebView2Samples

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.