Skip to content

Handle CreateCoreWebView2EnvironmentWithOptions ERROR_NOT_SUPPORTED - #3500

Open
r-mennig wants to merge 1 commit into
eclipse-platform:masterfrom
r-mennig:fix_edgedir_handling
Open

Handle CreateCoreWebView2EnvironmentWithOptions ERROR_NOT_SUPPORTED#3500
r-mennig wants to merge 1 commit into
eclipse-platform:masterfrom
r-mennig:fix_edgedir_handling

Conversation

@r-mennig

Copy link
Copy Markdown
Contributor

When passing a Edge binary directory to
'org.eclipse.swt.browser.EdgeDir',
CreateCoreWebView2EnvironmentWithOptions
returns HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) instead of HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) which is thrown for other invalid directories.

In this case, the passed completion callback exits immediately before the processOSMessagesUntil(..) loop starts spinning. This previously caused the return value being overwritten in callAndWait(long[], ToIntFunction), leading to a permanent UI freeze.

Fixes #3499

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Test Results (win32)

   35 files  ±0     35 suites  ±0   5m 45s ⏱️ +35s
4 868 tests ±0  4 792 ✅ ±0  76 💤 ±0  0 ❌ ±0 
1 395 runs  ±0  1 371 ✅ ±0  24 💤 ±0  0 ❌ ±0 

Results for commit b5a92d6. ± Comparison against base commit 3241511.

♻️ This comment has been updated with latest results.

Comment on lines +652 to +654
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));
}

@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)

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.

@r-mennig
r-mennig force-pushed the fix_edgedir_handling branch from 1aad45d to 7d8dcc5 Compare August 12, 2026 15:53
return phr[0];
}

int callAndWait(String[] pstr, ToIntFunction<IUnknown> callable) {

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.

Although this method was not involved in causing this bug, it still has the same underlying problem as the other callAndWait method (overwriting the return value if the callback exits before the event loop spinning happens). That's why I also changed the code here

@fedejeanne fedejeanne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can reproduce the error in #3499 by passing this VM argument in my Launch Configuration (I launched the application org.eclipse.ui.ide.workbench) and opening the internal web browser:

-Dorg.eclipse.swt.browser.EdgeDir="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\151.0.4129.72"

And double-checked the correct usage by passing this instead (no freeze occurred):

-Dorg.eclipse.swt.browser.EdgeDir="C:\\Program Files (x86)\\Microsoft\\EdgeWebView\\Application\\151.0.4129.72"

With this PR there is no freeze with either parameter ✔️

I only have some minor comments regarding unnecessary formatting and about wording in the documentation.

Once those are done, I approve 👍

Are we delaying this until M1 or do we push it for M3? It looks pretty harmless to me and getting rid of UI freezes is always a plus so I'd merge it right away.

Comment thread bundles/org.eclipse.swt/Readme.WebView2.md Outdated
@r-mennig

r-mennig commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Are we delaying this until M1 or do we push it for M3? It looks pretty harmless to me and getting rid of UI freezes is always a plus so I'd merge it right away.

Thanks for the review! I would propose delaying this until M1. After all, the problem only occurs if a system property is misconfigured (although this is hard to tell for a user with the current implementation)

When passing a Edge binary directory to
'org.eclipse.swt.browser.EdgeDir',
CreateCoreWebView2EnvironmentWithOptions
returns HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) instead of
HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) which is thrown for other
invalid directories.

In this case, the passed completion callback exits immediately before
the processOSMessagesUntil(..) loop starts spinning. This previously
caused the return value being overwritten in callAndWait(long[],
ToIntFunction<IUnknown>), leading to a permanent UI freeze.

Fixes eclipse-platform#3499

@fedejeanne fedejeanne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To be merged in M1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing an Edge application directory to 'org.eclipse.swt.browser.EdgeDir' causes a permanent UI freeze when opening an internal browser

2 participants