Community
Participate
Working Groups
Win10 -Dorg.eclipse.swt.browser.DefaultType=edge Microsoft.WebView2.FixedVersionRuntime.90.0.818.66.x64 SWT v4946r10 Click on the link and error occurs. Apllication crashes. Example code: package aTests; import java.net.MalformedURLException; import java.net.URL; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.LocationListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class WebView2DeadLock { public static void main(String [] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("WebView2DeadLock"); final Browser browser = new Browser(shell, SWT.EDGE); shell.open(); browser.setText("<!DOCTYPE html><html><body>" + "<p>Click the button to open a new browser window.</p>" + "<a href=\"http://eclipse.org\">Try it</a>" + "</body></html>"); browser.addLocationListener(LocationListener.changingAdapter(e -> { if (!e.location.contains("eclipse.org")) return; Shell sh = new Shell(e.display); sh.setLayout(new FillLayout()); Browser br = new Browser(sh, SWT.NONE); try { br.setUrl(new URL(e.location).toExternalForm()); } catch (MalformedURLException ex) { } })); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } Exception: Exception in thread "main" org.eclipse.swt.SWTException: Failed to evaluate javascript expression [WebView2: deadlock detected] at org.eclipse.swt.SWT.error(SWT.java:4893) at org.eclipse.swt.browser.Edge.checkDeadlock(Edge.java:147) at org.eclipse.swt.browser.Edge.create(Edge.java:210) at org.eclipse.swt.browser.Browser.<init>(Browser.java:99) at aTests.WebView2DeadLock.lambda$0(WebView2DeadLock.java:31) at org.eclipse.swt.browser.LocationListener$1.changing(LocationListener.java:81) at org.eclipse.swt.browser.Edge.handleNavigationStarting(Edge.java:446) at org.eclipse.swt.browser.Edge.handleNavigationStarting(Edge.java:428) at org.eclipse.swt.browser.Edge.lambda$0(Edge.java:87) at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3624) at aTests.WebView2DeadLock.main(WebView2DeadLock.java:38)
Please check fixed code in attachments
Created attachment 286719 [details] Example
Not reproducible using WebView 120.0.2210.144, can be closed
My bad, still reproducible with example (eclipse platform 4-27, WebView2 120.0.2210.144) public class WebView2DeadLock { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("WebView2DeadLock"); final Browser browser = new Browser(shell, SWT.EDGE); shell.open(); browser.setText("<!DOCTYPE html><html><body>" + "<p>Click the button to open a new browser window.</p>" + "<a href=\"http://eclipse.org\">Try it</a>" + "</body></html>"); browser.addLocationListener(LocationListener.changingAdapter(e -> { if (!e.location.contains("eclipse.org")) return; Shell sh = new Shell(e.display); sh.setLayout(new FillLayout()); Browser br = new Browser(sh, SWT.EDGE); try { br.setUrl(new URL(e.location).toExternalForm()); } catch (MalformedURLException ex) { } e.doit = false; })); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }