Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,16 @@ static int callAndWait(long[] ppv, ToIntFunction<IUnknown> callable) {
return COM.S_OK;
});
ppv[0] = 0;
phr[0] = callable.applyAsInt(completion);
// "completion" callback may be called asynchronously,
// so keep processing next OS message that may call it
processOSMessagesUntil(() -> phr[0] != COM.S_OK || ppv[0] != 0, exception -> {
throw exception;
}, Display.getCurrent());
int cr = callable.applyAsInt(completion);
if (cr != COM.S_OK) {
phr[0] = cr;
} else {
// "completion" callback may be called asynchronously,
// so keep processing next OS message that may call it
processOSMessagesUntil(() -> phr[0] != COM.S_OK || ppv[0] != 0, exception -> {
throw exception;
}, Display.getCurrent());
}
completion.Release();
return phr[0];
}
Expand All @@ -325,12 +329,16 @@ int callAndWait(String[] pstr, ToIntFunction<IUnknown> callable) {
return COM.S_OK;
});
pstr[0] = null;
phr[0] = callable.applyAsInt(completion);
// "completion" callback may be called asynchronously,
// so keep processing next OS message that may call it
processOSMessagesUntil(() -> phr[0] != COM.S_OK || pstr[0] != null, exception -> {
throw exception;
}, browser.getDisplay());
int cr = callable.applyAsInt(completion);
if (cr != COM.S_OK) {
phr[0] = cr;
} else {
// "completion" callback may be called asynchronously,
// so keep processing next OS message that may call it
processOSMessagesUntil(() -> phr[0] != COM.S_OK || pstr[0] != null, exception -> {
throw exception;
}, browser.getDisplay());
}
completion.Release();
return phr[0];
}
Expand Down Expand Up @@ -645,6 +653,9 @@ WebViewEnvironment createEnvironment() {
if (hr == OS.HRESULT_FROM_WIN32(OS.ERROR_FILE_NOT_FOUND)) {
SWT.error(SWT.ERROR_NOT_IMPLEMENTED, null, " [WebView2 runtime not found]");
}
if (hr == OS.HRESULT_FROM_WIN32(OS.ERROR_NOT_SUPPORTED)) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT, null, String.format(" [Invalid WebView2 directory: %s. Please ensure that '%s' points to a WebView2 application directory (which usually ends with \\EdgeWebView\\Application\\<Version>)]", browserDir, BROWSER_DIR_PROP));
}
Comment on lines +656 to +658

@r-mennig r-mennig Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found no reasonable way to write a unit test for this error code.

The documentation states that this error should be thrown if the given browserExecutableFolder contains the string \Edge\Application

Image

I could not verify this in testing, it seems like the folder path doesn't actually matter here.

Instead, it seems like some other criteria is used to tell the Edge binary folder apart from the WebView2 folder (likely the different .exe files msedge.exe / msedgewebview2.exe but I could not find any further information on this).

The only way I found to reproduce this error is by setting the system property to an actual Edge binary installation (which would add way too much overhead for such a small change)

if (hr != COM.S_OK) error(SWT.ERROR_NO_HANDLES, hr);
ICoreWebView2Environment environment = new ICoreWebView2Environment(ppv[0]);
WebViewEnvironment environmentWrapper = new WebViewEnvironment(environment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ public class OS extends C {
public static final int EN_CHANGE = 0x300;
public static final int EP_EDITTEXT = 1;
public static final int ERROR_FILE_NOT_FOUND = 0x2;
public static final int ERROR_NOT_SUPPORTED = 0x32;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public static final int ERROR_INVALID_STATE = 0x139F;
public static final int ERROR_NO_MORE_ITEMS = 0x103;
public static final int ERROR_CANCELED = 0x4C7;
Expand Down
4 changes: 3 additions & 1 deletion bundles/org.eclipse.swt/Readme.WebView2.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ the `Browser` will automatically fall back to the Internet Explorer backend.
### Browser Directory

WebView2 backend will automatically locate runtimes and Edge installations.
The path to the Edge binary directory can also be set manually using the
The path to the WebView2 binary directory can also be set manually using the
`org.eclipse.swt.browser.EdgeDir` system property. This is also
required when bundling fixed-version WebView2 binaries.

_Note_: The directory pointed to by `org.eclipse.swt.browser.EdgeDir` must contain the WebView2 binary (`msedgewebview2.exe`, usually in `\EdgeWebView\Application\<Version>`), **not** the Edge application binary (`msedge.exe`, usually in `\Edge\Application\<Version>`).

### User Directory

WebView creates a user data directory to stores caches and
Expand Down
Loading