Tracktion / choc

A collection of header only classes, permissively licensed, to provide basic useful tasks with the bare-minimum of dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple instances of a CHOC WebView Fails in Windows

jackkilgore opened this issue · comments

The Issue:

I am helping with development of two audio plugins, let's call them A and B for simplicity. When I load in A and then B with the WebView of A still open, the WebView of B is blank. Loading them by themselves has no issues. Also note that if I run multiple instances of B the issue does not occur.

When doing some digging, I saw that the constructor of choc::ui::Webview is failing.
The following code prints out false.

webView = std::make_unique<choc::ui::WebView>(opts);
std::cout << webView->loadedOK() << std::endl;

After doing some more digging I noticed that the PIMPL constructor is failing.
The line hwnd = windowClass.createWindow (WS_POPUP, 400, 400, this); returns a null pointer. This can be fixed by changing the first parameter of WindowClass windowClass { L"CHOCWebView", (WNDPROC) wndProc }; to something unique. WindowClass windowClass { L"CHOCWebView", (WNDPROC) wndProc }; -> WindowClass windowClass { L"CHOCWebViewB", (WNDPROC) wndProc };. This fixes when hwnd is null, but it unfortunately doesn't fix the entire issue.

Now the issue is that createEmbeddedWebView() is returning false because coreWebView is null. After doing some tracing, this has lead to HRESULT STDMETHODCALLTYPE Invoke (HRESULT, ICoreWebView2Controller* controller) override. This function seems to be called by the Window's WebView2 specifically . The controller is a null pointer only in the failing issue stated above.

I'm not sure what do as this gets into WebView2 calls.

If you need help replicating the bug let me know!

This sounds like a bug that I fixed yesterday - try the latest version!
There was a discussion about it all on discord, you might want to check it out: https://discord.com/channels/382895736356077570/1218213251553165393

Woah. What are the odds :000

It fixed our issue once we update CHOC in both plugins, thanks so much!!