-
Notifications
You must be signed in to change notification settings - Fork 182
Description
In our RCP application we see no more handle exceptions during startup if we use Edge. This does not happen all the time, there seems to be a race condition or the error is reported incorrectly similar to https://bugs.eclipse.org/bugs/show_bug.cgi?id=576196.
If the user starts again the RCP application, the errors does not happen again, sometimes is takes 3-4 attempts to start the application. We are using latest version from https://developer.microsoft.com/de-de/microsoft-edge/webview2/#download-section, currently 104.0.1293.63 pointing to the download with -Dorg.eclipse.swt.browser.DefaultType=edge -Dorg.eclipse.swt.browser.EdgeDir=c:\PROGRA~1\WebView2 in the runtime arguments.
This happens in the Edge.createmethod, relevant stack trace:
org.eclipse.swt.SWTError: No more handles [0x8007139f]
at org.eclipse.swt.SWT.error(SWT.java:4944)
at org.eclipse.swt.browser.Edge.error(Edge.java:190)
at org.eclipse.swt.browser.Edge.create(Edge.java:343)
at org.eclipse.swt.browser.Browser.<init>(Browser.java:99)
at de.example.rcp.base.views.NavigationPanelView.createPartControl(NavigationPanelView.java:242)
Here is the code which triggers the exception:
try {
if (hiddenBrowser == null || hiddenBrowser.isDisposed()) {
hiddenBrowser = new Browser(bar, SWT.EDGE);
hiddenBrowser.setBounds(0, 0, 0, 0);
hiddenBrowser.setVisible(false);
}
} catch (Exception | Error e) {
LOG.warn("Unable to create hidden browser", e);
}
callAndWait seems to spins the event queue, maybe this causes the other thread to sync with main thread and to dispose the composite?
static int callAndWait(long[] ppv, ToIntFunction<IUnknown> callable) {
int[] phr = {COM.S_OK};
IUnknown completion = newCallback((result, pv) -> {
phr[0] = (int)result;
if ((int)result == COM.S_OK) {
ppv[0] = pv;
new IUnknown(pv).AddRef();
}
return COM.S_OK;
});
ppv[0] = 0;
phr[0] = callable.applyAsInt(completion);
completion.Release();
Display display = Display.getCurrent();
while (phr[0] == COM.S_OK && ppv[0] == 0) {
if (!display.readAndDispatch()) display.sleep();
}
return phr[0];
}
The incorrect behavior reported via https://bugs.eclipse.org/bugs/show_bug.cgi?id=576196 can be reproduced with the following snippet.
public void createComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
for (int i = 0; i <= 10; i++) {
System.out.println("Iteration " + i);
Composite c = new Composite(parent, SWT.NONE);
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
c.dispose();
}
});
Browser browser = null;
if (!c.isDisposed()) {
browser = new Browser(c, SWT.EDGE);
}
if (browser != null) {
browser.dispose();
}
}
}
Expected behavior
Correct error message or even better, just working.
Environment:
- Select the platform(s) on which the behavior is seen:
-
- All OS
-
- Windows
-
- Linux
-
- macOS
-
Additional OS info (e.g. OS version, Linux Desktop, etc)
-
JRE/JDK version
Java 11
Version since
Still present in latest I-Buil
Workaround (or) Additional context
Start again the RCP application.