Community
Participate
Working Groups
Created attachment 287760 [details] simple html that invokes a BrowserFunction In this simple example, there are three identical browsers. Each with a html button that sends some dummy data to BrowserFunction. They all work fine. If I launch a second instance of the same app. The browser and html shows up but no BrowserFunction is ever triggered. I first noticed this problem in a more complex app where there are multiple JFace Dialogs showing at the same time, each with an Edge browser. This is only a problem in Edge/WebView2 implementation. The same code works on OSX and Windows IE 11 mode.
Created attachment 287761 [details] simple app
Hi! Expiriencing the same issue. Could anybody advice is there any solutions or workaround for that issue?
Please try: browser.getDisplay().asyncExec(()->{ final File testFile = new File(EdgeBrowserTest.class.getResource("EdgeBrowserTest.html").toURI()); browser.setUrl(testFile.toURI().toString()); }); instead of calling browser.setUrl(..) directly after registering the BrowserFunction. That seems to cure the problem in our code at least.
Tried the workarround proposed but was not successfull for us :( Our usage is a browser within a specialized EcoreEditor, we encounter the same bad behavior: first tab work perfect, second open tab start withoyut having any BrowserFunction loaded.
My team managed to get the issue resolved by setting the BrowserFunction inside ProgressAdapter#completed(). See example below (commented out code was before changes): public EdgeUpliftBrowserWindow(Shell parent) { // Browser browser = new Browser(parent, SWT.EDGE); // new OpenTestWindow(browser); // browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // browser.setUrl(HTML_RESOURCE); Browser browser = new Browser(parent, SWT.EDGE); browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); browser.addProgressListener(new ProgressAdapter() { @Override public void completed(ProgressEvent event) { new OpenTestWindow(browser); } }); browser.setUrl(HTML_RESOURCE); } private final class OpenTestWindow extends BrowserFunction { public OpenTestWindow(Browser browser) { super(browser, "openTestWindow"); //$NON-NLS-1$ } @Override public String function(Object[] arguments) { System.out.println("Function Has Been Called!"); //$NON-NLS-1$ return null; } }