Skip to content

Commit

Permalink
[Win32] Spin event loop in Edge instead of processing OS messages ecl…
Browse files Browse the repository at this point in the history
…ipse-platform#1771

Before recent improvements of the Edge implementation, it was possible
that a browser instance was disposed during WebView initialization,
which made the initialization fail exceptionally. This has been
worked around by not processing all kinds of asynchronously scheduled
events (like a disposal) while waiting for WebView initialization but
only those being processes by the OS event queue. This was still
necessary to process the OS callbacks for WebView initialization and
other operations.

In some cases, this may lead to an Edge browser instance blocking the UI
thread, as some asynchronously scheduled tasks need to be processed but
are not. In addition, enhancements of the Edge implementation made the
initialization happen asynchronously anyway, such that the browser
instantiation itself cannot throw an error anymore, but the
asynchronously happening initialization is now capable of processing
asynchronous browser disposals.

This change simplifies the event processing inside Edge to not only
process the next OS message but to just ordinarily spin the event loop.
This reduces the risk of operations executed on an Edge browser to block
execution.

eclipse-platform#1771
  • Loading branch information
HeikoKlare committed Jan 29, 2025
1 parent bff91d7 commit 1ffe51f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Rule;
Expand Down Expand Up @@ -157,6 +158,16 @@ public Test_org_eclipse_swt_browser_Browser(int swtBrowserSettings) {
this.swtBrowserSettings = swtBrowserSettings;
}

@BeforeClass
public static void setupEdgeEnvironment() {
// initialize Edge environment before any test runs to isolate environment setup
if (SwtTestUtil.isWindows) {
Shell shell = new Shell();
new Browser(shell, SWT.EDGE);
shell.dispose();
}
}

@Override
@Before
public void setUp() {
Expand Down Expand Up @@ -295,7 +306,7 @@ private Browser createBrowser(Shell s, int flags) {
}

private Browser createBrowser(Shell s, int flags, boolean expectSuccess) {
long maximumBrowserCreationMilliseconds = 20_000;
long maximumBrowserCreationMilliseconds = 90_000;
long createStartTime = System.currentTimeMillis();
Browser b = new Browser(s, flags);
// Wait for asynchronous initialization via getting URL
Expand Down

0 comments on commit 1ffe51f

Please sign in to comment.