Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge: properly handle initialization failures and abortion #1578

Merged

Conversation

HeikoKlare
Copy link
Contributor

@HeikoKlare HeikoKlare commented Nov 7, 2024

There is currently only few handling for failures during initialization of an Edge browser / WebView instance. The Microsoft documentation provides further information on this, in particular:

  • ERROR_INVALID_STATE indicates that multiple Edge instances with the same data folder but different environment options exist
  • E_ABORT indicates an active abortion of the initialization process
  • On any other non-OK return value than the above ones, the app should retry initialization of the instance

This change adds appropriate handling for these scenarios, consisting of uniform rollback logic when the initialization fails or is aborted and retry logic to make repeated creation attempts.

Contributes to #1664

@HeikoKlare HeikoKlare force-pushed the edge-initialization-abortion branch from c35cfc6 to 86c452d Compare November 7, 2024 14:06
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Test Results

   486 files  ±0     486 suites  ±0   10m 15s ⏱️ +52s
 4 307 tests ±0   4 294 ✅ ±0   13 💤 ±0  0 ❌ ±0 
16 412 runs  ±0  16 304 ✅ ±0  108 💤 ±0  0 ❌ ±0 

Results for commit ca41f1e. ± Comparison against base commit 6104592.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare force-pushed the edge-initialization-abortion branch 3 times, most recently from 7d26fe6 to 8f4589a Compare January 2, 2025 09:36
@HeikoKlare HeikoKlare marked this pull request as ready for review January 2, 2025 10:13
@HeikoKlare HeikoKlare requested a review from sratz January 2, 2025 10:14
@HeikoKlare
Copy link
Contributor Author

HeikoKlare commented Jan 2, 2025

@amartya4256 I cannot add you as a reviewer via GitHub tooling, but maybe you can still have a look at this one?

Copy link
Contributor

@amartya4256 amartya4256 left a comment

Choose a reason for hiding this comment

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

The changes look good to me. I have just added 2 suggestions. Also I came across these: MicrosoftEdge/WebView2Feedback#2495, MicrosoftEdge/WebView2Feedback#3008

It might be intersting for the error code 139f.

System.err.println(String.format("Edge initialization failed, retrying (attempt %d / %d)", previousAttempts + 1, MAXIMUM_CREATION_RETRIES));
createInstance(previousAttempts + 1);
} else {
System.err.println(String.format("Aborting Edge initialiation after %d retries", MAXIMUM_CREATION_RETRIES));
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we should also throw an error here since the initialization was not successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, makes sense. I adapted this to throw an error instead of just printing an error message with ca41f1e.

@@ -457,6 +457,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_INVALID_STATE = 0x139F;
Copy link
Contributor

@amartya4256 amartya4256 Jan 3, 2025

Choose a reason for hiding this comment

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

isn't 0x8007139F also a COMException and hence should be put in COM.java?
Refer these: MicrosoftEdge/WebView2Feedback#2495, MicrosoftEdge/WebView2Feedback#3008

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ERROR_INVALID_STATE == 0x139f is an ordinary Windows error code (see https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--4000-5999-), just like the other ordinary Windows error codes we have in OS (like ERROR_NO_MORE_ITEMS). So I would say it is correctly placed in OS.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh alright then its all good

@HeikoKlare HeikoKlare force-pushed the edge-initialization-abortion branch from 8f4589a to 38178e9 Compare January 3, 2025 17:02
There is currently only few handling for failures during initialization
of an Edge browser / WebView instance. The Microsoft documentation
provides further information on this, in particular:
- ERROR_INVALID_STATE indicates that multiple Edge instances with the
same data folder but different environment options exist
- E_ABORT indicates an active abortion of the initialization process
- On any other non-OK return value than the above ones, the app should
retry initialization of the instance; to avoid endless waiting, the
number of retries is currently limited to 5

This change adds appropriate handling for these scenarios, consisting of
uniform rollback logic when the initialization fails or is aborted and
retry logic to make repeated creation attempts.

Contributes to
eclipse-platform#1664
@HeikoKlare HeikoKlare force-pushed the edge-initialization-abortion branch from 38178e9 to ca41f1e Compare January 3, 2025 17:05
Copy link
Member

@sratz sratz left a comment

Choose a reason for hiding this comment

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

lgtm

@HeikoKlare
Copy link
Contributor Author

Thank you for your reviews!

@HeikoKlare HeikoKlare merged commit d7febc4 into eclipse-platform:master Jan 7, 2025
14 checks passed
@HeikoKlare HeikoKlare deleted the edge-initialization-abortion branch January 7, 2025 16:51
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.

No more handles when creating Edge browser
3 participants