Open daniemur opened 1 year ago
The root cause for this behavior is that the WebView2 threading model does simply not allow this: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/threading-model All handlers and callbacks are processed sequentially. Triggering another event from within a callback (as done in the example) leads to a deadlock.
A potential solution option is to execute whatever code is embedded into a callback in an asynchronous way. But since the current browser API is expected to operate synchronously and return results rather than futures, this may easily break compatibility.
At least the Edge browser implementation usually checks for these kinds of deadlocks and throws an exception rather than actually running into a deadlock: https://github.com/eclipse-platform/eclipse.platform.swt/blob/863dbe09a63f7a619320b90d19f8184e3f5d5959/bundles/org.eclipse.swt/Eclipse%20SWT%20Browser/win32/org/eclipse/swt/browser/Edge.java#L285-L293
At this specific point (handleCallJava
), the deadlock check is missing. This is something we may fix.
Summary
Edge
Browser
freezes indefinitely when launching one Browser ("child" Browser) from another ("parent" Browser) via aBrowserFunction
usingDisplay#syncExec
to create the child Browser. The same behavior is not exhibited when the child Browser is created within aDisplay#asyncExec
call.Also want to note when SWT gets into this waiting state, closing the window does not kill the process. The process will run until killed manually.
Code To Reproduce
Stack Trace
SWT waits indefinitely on the org.eclipse.swt.internal.win32.OS.WaitMessage call below:
Expected behavior The child Browser opens successfully.
Environment:
Version since SWT 3.117-Current (3.123 at the time of writing this)
Known Workarounds
Display#asyncExec
instead ofDisplay#syncExec
to create the child Browser