HelloWebView contains race condition
@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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MicrosoftEdge/WebView2Samples
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 72/100
MicrosoftEdge/WebView2Samples#5 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
MicrosoftEdge/WebView2Samples#282 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
MicrosoftEdge/WebView2Samples#277 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
MicrosoftEdge/WebView2Samples#273 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
MicrosoftEdge/WebView2Samples#268 ·
All issues in MicrosoftEdge/WebView2Samples
Similar issues
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
flashinfer-ai/flashinfer#6212 ·
Maintainers usually reply within 1 day
-
bug graphics
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
FlaxEngine/FlaxEngine#4295 · 2 comments ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Algorithmiq/monoprop#390 ·
Maintainers usually reply within 1 day
-
docs
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
leethomason/tinyxml2#1097 ·