|
| 1 | +# FAQ How do I use Edge/IE as the Browser's underlying renderer? |
| 2 | + |
| 3 | +Since Eclipse/SWT 4.35 (2025-03) Edge is used as the default browser in SWT. For older releases, browser instances using Edge could be created with the style `SWT.EDGE` (since 4.19) or setting the Java property `org.eclipse.swt.browser.DefaultType=edge`. |
| 4 | + |
| 5 | +## WebView2 Component Provision |
| 6 | + |
| 7 | +Edge rendering backend uses the WebView2 component, which is based on but distinct from the Edge browser itself. SWT relies on a WebView2 component being available on the current system. |
| 8 | +There are different [ways of distribution for the WebView2 component](https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution). On most systems, the component is already available due to the `Evergreen runtime distribution mode` ensuring the availability of an automatically updated version of the library on Windows. |
| 9 | + |
| 10 | +If this is not the case or if other versions of the component shall be used, these options exist: |
| 11 | +* A stand-alone runtime installer, either web or offline ([Download the WebView2 Runtime](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#webview-title) from Microsoft). |
| 12 | + This runtime will be shared between all applications on the machine and will auto-update itself independent of your application. |
| 13 | +* A fixed-version archive with all the necessary files (same link as above). |
| 14 | + This is a complete, fixed set of files to be included with your application. Unlike the first option, you have complete freedom in bundling, packaging and updating it. |
| 15 | +* Beta, Dev, or Canary version of the Edge browser (<https://www.microsoftedgeinsider.com/en-us/download>). |
| 16 | + This option is convenient for testing, but production deployments should use the previous two options. |
| 17 | + |
| 18 | +SWT will automatically locate installed browsers and runtimes (using the `WebView2Loader.dll` provided via the SWT fragment for Windows). |
| 19 | +In case you want to use fixed-version binaries or override the automatically chosen version, set the `org.eclipse.swt.browser.EdgeDir` Java property to the directory containing `msedgewebview2.exe`. For example, you can add `-Dorg.eclipse.swt.browser.EdgeDir=PATH_TO_EDGE` with `PATH_TO_EDGE` being the absolute path to an Edge installation as a command-line argument to an SWT application or to the `eclipse.ini` of an Eclipse product. |
| 20 | + |
| 21 | +## WebView2 Data Directory |
| 22 | + |
| 23 | +WebView2 creates a user data directory to store caches and persistent data like cookies and local storage. All WebView2 instances in an application and all instances of the same application share this directory. |
| 24 | + |
| 25 | +The default user directory is customizable and depends on the usage context: |
| 26 | +* In a plain SWT application, the default location is `%LOCALAPPDATA%\<AppName>\EBWebView`, where `<AppName>` is defined with `Display.setAppName()`. |
| 27 | +* In an Eclipse product, the default location is inside the metadata folder of the workspace, precisely in `.metadata\.plugins\org.eclipse.swt\EBWebView`. |
| 28 | +* The location can be customized by specifying it on a per-process basis via the `org.eclipse.swt.browser.EdgeDataDir` Java property. |
| 29 | + |
| 30 | +## WebView2 Timeouts |
| 31 | + |
| 32 | +All operations on a WebView2 component are executed asynchronously, including it's initialization. Under some conditions and in some environments, operations can take rather long, which is why the WebView2 adaptation in SWT uses timeouts to avoid UI blocks. |
| 33 | +In case you run into such timeouts and want to increase the timeout value, you can do so via the `org.eclipse.swt.internal.win32.Edge.timeout` property, which accepts a timeout value in milliseconds. |
| 34 | + |
| 35 | +## Fallback to Internet Explorer |
| 36 | + |
| 37 | +Beginning with 4.35, browser instances in Eclipse/SWT application will use Edge by default and need to be created with style `SWT.IE` or via setting the Java property `org.eclipse.swt.browser.DefaultType=ie` to still use the Internet Explorer. |
0 commit comments