1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Windows: Fix faulty mechanism for creating multiple WebView2 instances serially

Prior to this commit it was possible for the WebBrowserComponent
implementation on Windows to end up in an infinite loop if multiple
WebBrowserComponent objects were being created at the same time.

When an instance was already being created, the createWebView() call for
the second would place it in a queue and return without initiating its
creation. When the first WebView finishes creation, it calls the
handleAsyncUpdate() function of the second. However handleAsyncUdpate()
would see that the webViewBeingCreated helper variable was already true
and not call createWebView(), hence the second WebView would never be
created.

If, in the meantime, the scriptsWaitingForExecution variable wasn't
empty, handleAsyncUpdate() would endlessly call triggerAsyncUpdate().
This commit is contained in:
attila 2025-01-17 16:12:51 +01:00
parent 612c50f4a4
commit 90e72dbd98

View file

@ -686,7 +686,6 @@ public:
if (webView == nullptr)
{
scriptsWaitingForExecution.push_back ({ script, std::move (callbackIn) });
triggerAsyncUpdate();
return;
}
@ -1059,6 +1058,7 @@ private:
{
if (weakThis != nullptr)
{
weakThis->triggerAsyncUpdate();
webView2ConstructionHelper.webView2BeingCreated = nullptr;
if (controller != nullptr)
@ -1156,15 +1156,9 @@ private:
//==============================================================================
void handleAsyncUpdate() override
{
if (webView == nullptr && ! webViewBeingCreated)
if (webView == nullptr)
{
webViewBeingCreated = true;
createWebView();
}
if (webView == nullptr && ! scriptsWaitingForExecution.empty())
{
triggerAsyncUpdate();
return;
}
@ -1206,7 +1200,6 @@ private:
WebViewHandle webViewHandle;
ComSmartPtr<ICoreWebView2Controller> webViewController;
ComSmartPtr<ICoreWebView2> webView;
bool webViewBeingCreated = false;
EventRegistrationToken navigationStartingToken { 0 },
newWindowRequestedToken { 0 },