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

WIP: Edge Browser Scheduled Job timeout #1752

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amartya4256
Copy link
Contributor

No description provided.

@amartya4256 amartya4256 force-pushed the edge_timeout branch 2 times, most recently from 7d16ca0 to 8195777 Compare January 22, 2025 12:01
@fedejeanne
Copy link
Contributor

fedejeanne commented Jan 22, 2025

I would additionally reduce the timeout introduced in #1677 to 10 seconds (+5 seconds from your new timeout) just to make sure that your change here actually covers all failing tests and use cases. If it does then I would expect to see no timeouts hitting 10s, only timeouts after 5s.

WDYT?

Copy link
Contributor

github-actions bot commented Jan 22, 2025

Test Results

   493 files  +  1     493 suites  +1   13m 36s ⏱️ + 6m 43s
 4 293 tests +190   4 083 ✅  -  13   8 💤 +1  0 ❌ ±0  202 🔥 +202 
16 531 runs  +380  16 232 ✅ +173  97 💤 +5  0 ❌ ±0  202 🔥 +202 

For more details on these errors, see this check.

Results for commit ae4fcac. ± Comparison against base commit 413426e.

♻️ This comment has been updated with latest results.

@amartya4256
Copy link
Contributor Author

I would additionally reduce the timeout introduced in #1677 to 10 seconds (+5 seconds from your new timeout) just to make sure that your change here actually covers all failing tests and use cases. If it does then I would expect to see no timeouts hitting 10s, only timeouts after 5s.

WDYT?

Alright, I'll add it here.

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

I think we need to have another thorough look at what may cause Edge initialization to block the UI thread. When trying to test the timeout logic, I came across several places where I can introduce blocking operations that will not be caught by this proposal.

When systematically going through the public methods of Edge, I see that the calls to getWebView*() and isWebView*Availabile() are the ones that block in case initialization or any of the subsequently scheduled futures do not finish timely.
Then, taking a look at which calls may potentially block inside those methods, I see these two:

  • waitForFutureToFinish()
  • future.join()

The latter will be captured for the initialization future by the timeout added in this PR. The former will only partly be resolved, as inside waitForFutureToFinish() there is a call to processNextOSMessage(), which spins a loop that may be blocking as well. Thus, I think we need to break that potentially blocking operation as well. Maybe we can simply spin Display.readAndDisplay() in the loop checking for future completion (inside waitForFutureToFinish()) instead of having the additional loop inside processNextOSMessage()?

Then, what about the other callers of processNextOSMessage()? In particular, createEnvironment() is called synchronously when creating the first Edge instance. May that one block as well? I also see further calls of that method of which I am not sure if they are correct. We need to check them as well.

webViewFuture.orTimeout(1, TimeUnit.MILLISECONDS).exceptionally(exception -> {
// Throw exception on the Display thread directly to prevent CompletableFuture
// to wrap the exception and throw it silently
browser.getDisplay().execute(() -> SWT.error(SWT.ERROR_UNSPECIFIED, exception, "Edge Browser initialization timed out"));
Copy link
Contributor

Choose a reason for hiding this comment

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

In case we run into a timeout, the initialization needs to be properly rolled back in terms of the state of Edge being cleaned up and potentially OS resources to be freed, like in the abortion logic of createControllerInitializationCallback().

webViewFuture.orTimeout(1, TimeUnit.MILLISECONDS).exceptionally(exception -> {
// Throw exception on the Display thread directly to prevent CompletableFuture
// to wrap the exception and throw it silently
browser.getDisplay().execute(() -> SWT.error(SWT.ERROR_UNSPECIFIED, exception, "Edge Browser initialization timed out"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of only throwing an error, should we maybe hide the (uninitialized) browser widget and add a label informing the user about the failed initialization instead? Calling something like this inside the execution on display might do the trick:

	private void replaceWithErrorLabel() {
		browser.setVisible(false);
		Label errorLabel = new Label(browser.getParent(), SWT.WRAP);
		errorLabel.setForeground(browser.getDisplay().getSystemColor(SWT.COLOR_RED));
		errorLabel.setText("Edge browser initialization failed");
		errorLabel.setLocation(0, 0);
		errorLabel.setSize(browser.getSize());
	}

@amartya4256 amartya4256 linked an issue Jan 26, 2025 that may be closed by this pull request
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.

Application freezes due to using Edge
3 participants