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

Eclipse/Webkit browser crashes on Linux #843

Open
Phillipus opened this issue Oct 26, 2023 · 39 comments
Open

Eclipse/Webkit browser crashes on Linux #843

Phillipus opened this issue Oct 26, 2023 · 39 comments
Labels
Linux/GTK Happens on Linux Webkit

Comments

@Phillipus
Copy link
Contributor

Phillipus commented Oct 26, 2023

Describe the bug
The internal Browser is not rendering on Linux.

To Reproduce
Install latest Eclipse on Ubuntu 23.04 (X11 not Wayland) or Linux Mint 21.2 and do one of the following:

  • Open up the internal Browser and try to view a URL
  • Open the Welcome page to try to view the content
  • Hover over some Java to invoke the tooltip
  • Run a basic SWT Snippet to launch a Browser component and set the URL

Either the browser is blank, or sometimes using the Internal Browser View in Eclipse you might see a little of the content. It also seems to be hanging because there is a long delay closing Eclipse.

Expected behavior
Browser component should render on Linux.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)

Ubuntu 23.04
GTK 3.24.37

or:

Linux Mint 21.2
GTK 3.24.33

  1. JRE/JDK version

Temurin-17.0.8+7 (build 17.0.8+7)

Version since
Tested on Eclipse 4.27 and later

Workaround (or) Additional context
None

@akurtakov
Copy link
Member

Do you say it works with Wayland for you?
What is the webkitgtk version you have ? On fedora 39 with webkit2gtk4.1-2.42.1 internal web browser works just fine with both x11 and wayland for me.

@Phillipus
Copy link
Contributor Author

Do you say it works with Wayland for you?

I've now tested it with Wayland on Ubuntu and it works. But not working with X11.

I can't test Wayland on Linux Mint because that distro only supports X11.

What is the webkitgtk version you have

On Ubuntu I see these versions:

  • libwebkit2gtk-4.0-37
  • libwebkit2gtk-4.1-0
  • libwebkitgtk-6.0-4

@iloveeclipse
Copy link
Member

And which webkit is loaded by SWT?

@akurtakov
Copy link
Member

What is the webkitgtk version you have

On Ubuntu I see these versions:

* libwebkit2gtk-4.0-37
* libwebkit2gtk-4.1-0
* libwebkitgtk-6.0-4

You would have to be more specific as these are the so names (more or less) but the actual webkitgtk versions are 2.xx.x format (https://webkitgtk.org/) and I'm interested to see whether you have newer or older version (mine is 2.42.1).
Another thing that comes to my mind is to try uninstalling libwebkit2gtk-4.0 and recheck as SWT will prefer the old version (

handle = dlopen("libwebkit2gtk-4.0.so.37", LOAD_FLAGS); /* webkit2/libsoup2 */ \
) which may no longer be in the same shape as libwebkit2gtk-4.1. For what it works - Fedora drops 4.0 already.

@Phillipus
Copy link
Contributor Author

How do I get the specific versions?

@iloveeclipse
Copy link
Member

Go to Eclipse about dialog, software configuration, type SWT and get list of variables set by the framework.

@akurtakov
Copy link
Member

This is my Debian knowledge maximum - smth like apt show package_name should give you the info.

@Phillipus
Copy link
Contributor Author

Go to Eclipse about dialog, software configuration, type SWT and get list of variables set by the framework.

Sorry, can't see any libwebkit2gtk info there.

@Phillipus
Copy link
Contributor Author

Phillipus commented Oct 26, 2023

OK:

Ubuntu:

libwebkit2gtk-4.0-37:amd64         2.42.1-0ubuntu0.23.04.1
libwebkit2gtk-4.1-0:amd64          2.42.1-0ubuntu0.23.04.1
libwebkitgtk-6.0-4:amd64           2.42.1-0ubuntu0.23.04.1

Linux Mint:

libwebkit2gtk-4.0-37:amd64         2.42.1-0ubuntu0.22.04.1
libwebkit2gtk-4.1-0:amd64          2.42.1-0ubuntu0.22.04.1

@akurtakov
Copy link
Member

So same version (difference could come from distro patches still). Please try getting rid of libwebkit2gtk-4.0-37 for the sake of the experiment.

@akurtakov
Copy link
Member

You might be hitting https://bugzilla.redhat.com/show_bug.cgi?id=2240428 but I have no idea about debian/ubuntu GL/GLES naming to give you some more hints.

@Phillipus
Copy link
Contributor Author

Phillipus commented Oct 26, 2023

Another thing that comes to my mind is to try uninstalling libwebkit2gtk-4.0 and recheck as SWT will prefer the old version

Didn't fix it.

I rolled back to a snapshot of my Linux Mint installation that uses version 2.40.5 of libwebkit2gtk and that was OK. So must be something to do with version changes.

@Phillipus
Copy link
Contributor Author

More investigations using Linux Mint (non-Wayland), webkitgtk 2.42.1.

Using this snippet:

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class BrowserTest {

    public static void main(String[] args) {
        final Display display = new Display();

        final Shell shell = new Shell(display);
        shell.setText("Browser Test");
        shell.setLayout(new GridLayout());

        Browser browser = new Browser(shell, SWT.NONE);
        browser.setLayoutData(new GridData(GridData.FILL_BOTH));

        Button button = new Button(shell, SWT.PUSH);
        button.setText("Go");
        button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        button.addListener(SWT.Selection, event -> {
            browser.setUrl("https://www.eclipse.org");
        });

        shell.setSize(900, 700);
        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }

        display.dispose();
    }
}

Sometimes some of the website is rendered in the browser component but most times it is blank. Hovering the mouse over the window the cursor changes to indicate links. Pressing a (invisible) link or pressing the "Go" button a second time gives the following error after some time:

SWT call to Webkit timed out after 10000ms. No return value will be provided.
Possible reasons:
1) Problem: Your javascript needs more than 10000ms to execute.
   Solution: Don't run such javascript, it blocks Eclipse's UI. SWT currently allows such code to complete, but this error is thrown 
     and the return value of execute()/evalute() will be false/null.

2) However, if you believe that your application should execute as expected (in under10000 ms),
 then it might be a deadlock in SWT/Browser/webkit2 logic.
 I.e, it might be a bug in SWT (e.g this does not occur on Windows/Cocoa, but occurs on Linux). If you believe it to be a bug in SWT, then
Please report this issue *with steps to reproduce* via:
 https://bugs.eclipse.org/bugs/enter_bug.cgi?alias=&assigned_to=platform-swt-inbox%40eclipse.org&attach_text=&blocked=&bug_file_loc=http%3A%2F%2F&bug_severity=normal&bug_status=NEW&comment=&component=SWT&contenttypeentry=&contenttypemethod=autodetect&contenttypeselection=text%2Fplain&data=&defined_groups=1&dependson=&description=&flag_type-1=X&flag_type-11=X&flag_type-12=X&flag_type-13=X&flag_type-14=X&flag_type-15=X&flag_type-16=X&flag_type-2=X&flag_type-4=X&flag_type-6=X&flag_type-7=X&flag_type-8=X&form_name=enter_bug&keywords=&maketemplate=Remember%20values%20as%20bookmarkable%20template&op_sys=Linux&product=Platform&qa_contact=&rep_platform=PC&requestee_type-1=&requestee_type-2=&short_desc=webkit2_BrowserProblem
For bug report, please atatch this stack trace:
java.lang.Throwable: 
	at org.eclipse.swt.browser.WebKit.getStackTrace(WebKit.java:300)
	at org.eclipse.swt.browser.WebKit.getInternalErrorMsg(WebKit.java:293)
	at org.eclipse.swt.browser.WebKit$Webkit2AsyncToSync.execAsyncAndWaitForReturn(WebKit.java:1272)
	at org.eclipse.swt.browser.WebKit$Webkit2AsyncToSync.runjavascript(WebKit.java:1030)
	at org.eclipse.swt.browser.WebKit$Webkit2AsyncToSync.evaluate(WebKit.java:1000)
	at org.eclipse.swt.browser.WebKit.evaluate(WebKit.java:1299)
	at org.eclipse.swt.browser.WebKit.close(WebKit.java:865)
	at org.eclipse.swt.browser.WebKit.onDispose(WebKit.java:1792)
	at org.eclipse.swt.browser.WebKit.lambda$4(WebKit.java:768)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5855)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1529)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1555)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1534)
	at org.eclipse.swt.widgets.Widget.release(Widget.java:1337)
	at org.eclipse.swt.widgets.Control.release(Control.java:4803)
	at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:1560)
	at org.eclipse.swt.widgets.Canvas.releaseChildren(Canvas.java:279)
	at org.eclipse.swt.widgets.Decorations.releaseChildren(Decorations.java:503)
	at org.eclipse.swt.widgets.Shell.releaseChildren(Shell.java:3413)
	at org.eclipse.swt.widgets.Widget.release(Widget.java:1344)
	at org.eclipse.swt.widgets.Control.release(Control.java:4803)
	at org.eclipse.swt.widgets.Widget.dispose(Widget.java:543)
	at org.eclipse.swt.widgets.Shell.dispose(Shell.java:3330)
	at org.eclipse.swt.widgets.Shell.closeWidget(Shell.java:694)
	at org.eclipse.swt.widgets.Shell.gtk_delete_event(Shell.java:1537)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2495)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:6883)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:6163)
	at org.eclipse.swt.internal.gtk3.GTK3.gtk_main_do_event(Native Method)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1597)
	at org.eclipse.swt.internal.gtk3.GTK3.gtk_main_iteration_do(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4514)
	at BrowserTest.main(BrowserTest.java:44)

 Additional information about the error is as following:
 The following javascript was executed:
function SWTWebkit2TempFunc1(){return SWTExecuteTemporaryFunctionCLOSE(window);}; SWTWebkit2TempFunc1()

@dabicho
Copy link

dabicho commented Nov 8, 2023

I've got to google on the issue again
Seems like it's affecting a variety of tools that use webkitgtk 5.42.x webkit browsers

A workaround is to use the environment variable

WEBKIT_DISABLE_COMPOSITING_MODE=1

Since it seems to be about compositing i'm not sure it affects certain 'X' servers, or graphics drivers or even desktop environment

But I was affected with either Xorg or wayland, with kde plasma, gnome and enlightenment on Arch Linux with propietary nvidia 470xx drivers

UPDATE:

The environment variable
WEBKIT_DISABLE_DMABUF_RENDERER=1
works too

@Phillipus
Copy link
Contributor Author

@dabicho Thanks for the workaround, which is working for me on Linux Mint (X11). Do you know if this is something that will be fixed in webkitgtk?

@cyrilsochor
Copy link

WEBKIT_DISABLE_DMABUF_RENDERER=1 fixed my problem on Ubuntu 22.04.3 LTS, X11
apt list --installed | grep webkit
libqt5webkit5/jammy,now 5.212.0~alpha4-15ubuntu1 amd64 [installed,automatic]
libwebkit2gtk-4.1-0/jammy-updates,jammy-security,now 2.42.1-0ubuntu0.22.04.1 amd64 [installed]

@froshyfrosh
Copy link

Thanks @dabicho for the workaround, just for the record:
for me only WEBKIT_DISABLE_COMPOSITING_MODE=1 is working (WEBKIT_DISABLE_DMABUF_RENDERER=1 has no effect). Problem started after I finally updated Eclipse today, no other changes and before everything was working fine.

libwebkit2gtk-4.0-37:amd64 2.38.6-0ubuntu0.20.04.1

@akurtakov
Copy link
Member

@froshyfrosh It would be nice if you can install libwebkit2gtk-4.1 and try with today's I-build(https://download.eclipse.org/eclipse/downloads/drops4/I20240111-0700/) that contains 4d1d26a .

@iloveeclipse
Copy link
Member

We see also some webkit crashes on RHEL 7.9 but with different stack...
webkitgtk4-2.28.2-2 , crash looks like

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast(WebKitWebProcess:12468): Gdk-ERROR **: 17:13:53.815: The program 'WebKitWebProcess' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 163 error_code 2 request_code 151 (GLX) minor_code 34)

I'm curious where do you find all the WEBKIT_DISABLE_ variables?
Could you point to the source please?

@froshyfrosh
Copy link

@akurtakov Ok, I can try that next week. Today I'm working from home via xrdp on that machine and I just realized that this way it works even without any of those env. vars.

@froshyfrosh
Copy link

@akurtakov Sorry I forgot to check last time I was in the office. Today I did it, but I cannot reproduce it any more. Javadoc view and tooltips are working now without any environment variables set. I'm not aware of any changes/updates on this machine. Only a reboot (but I think I did that before and there it did not help then). If you want me to check something let me know.

@akurtakov
Copy link
Member

@Phillipus do you still face this issue? TBH, I lost track here but that's what happens when multiple reports end up in same issue thus I'm pointing to you as the one that opened it.

@Phillipus
Copy link
Contributor Author

Phillipus commented Jan 18, 2024

@Phillipus do you still face this issue?

Yes.

I'm testing on two Linux VMs - Ubuntu 23.04 and Linux Mint 21.3 (Ubuntu 22.04 base). These have latest package updates.

Running dpkg -l | grep libwebkit* gives:

Ubuntu 23.04

libwebkit2gtk-4.0-37:amd64       2.42.4-0ubuntu0.23.04.1
libwebkit2gtk-4.1-0:amd64        2.42.4-0ubuntu0.23.04.1
libwebkitgtk-6.0-4:amd64         2.42.4-0ubuntu0.23.04.1

Linux Mint 21.3

libwebkit2gtk-4.0-37:amd64         2.42.4-0ubuntu0.22.04.1
libwebkit2gtk-4.1-0:amd64          2.42.4-0ubuntu0.22.04.1

Note this is X11, not Wayland.

The following workaround is still working:

WEBKIT_DISABLE_COMPOSITING_MODE=1

@realDragon11
Copy link

Having the issue where opening various eclipse screens (the help contents and hover javadocs the most prominent) crashes it. Trying to install a fresh eclipse also resulted in the installer crashing.
Running dpkg -l | grep libwebkit* gives:
libwebkit2gtk-4.0-37:amd64 2.42.5-0ubuntu0.22.04.2
Using Lubuntu of Ubuntu 22.04.4 LTS.

WEBKIT_DISABLE_DMABUF_RENDERER=1 seems to fix the problem for eclipse but WEBKIT_DISABLE_COMPOSITING_MODE=1 did not.
I had been having very intermittent random crashes when hovering over javadocs prior to recently updating my system, but after updating it happened consistently. Hover javadocs do work with the setting set to disable.

@Dave-ts
Copy link

Dave-ts commented Mar 13, 2024

If you are running your Linux OS in a Virtual Environment (VMWare/VirtualBox), try disabling 3d Acceleration.

VBox: right click VM|Settings...|Display then uncheck Enable 3D Acceleration.
Sorry, I don't use VMWare so not sure where to find it in there.

We ran across this problem with another application, managed to work around it by doing the above.

@thomasintrouble
Copy link

WEBKIT_DISABLE_DMABUF_RENDERER=1 seems to fix the problem for eclipse
Thanks very much for this - worked for me on Fedora.

@akurtakov
Copy link
Member

Would you please try with https://download.eclipse.org/eclipse/downloads/drops4/I20240329-0530/ ? It should have a workaround for the problem.

@iloveeclipse iloveeclipse added Linux/GTK Happens on Linux Webkit labels Apr 22, 2024
iloveeclipse added a commit that referenced this issue May 21, 2024
Added note for Linux users about crash reporting/webkit

See #843
iloveeclipse added a commit that referenced this issue May 21, 2024
Added note for Linux users about crash reporting/webkit

See #843
@iloveeclipse iloveeclipse pinned this issue May 21, 2024
@iloveeclipse iloveeclipse changed the title Internal Browser not working on Linux Eclipse/Webkit browser crashes on Linux May 21, 2024
amartya4256 pushed a commit to amartya4256/eclipse.platform.swt that referenced this issue Jun 6, 2024
Added note for Linux users about crash reporting/webkit

See eclipse-platform#843
@MoritzWeber0
Copy link
Contributor

MoritzWeber0 commented Jul 4, 2024

In Eclipse Capella, the same issue appears with the description editor, which uses the internal browser too.

It makes the Eclipse completely unusable since the whole application freezes completely after a few seconds when the browser opens.
Neither WEBKIT_DISABLE_COMPOSITING_MODE=1 nor WEBKIT_DISABLE_DMABUF_RENDERER=1 work for me.

The stack trace is the same:

SWT call to Webkit timed out after 10000ms. No return value will be provided.
Possible reasons:
1) Problem: Your javascript needs more than 10000ms to execute.
   Solution: Don't run such javascript, it blocks Eclipse's UI. SWT currently allows such code to complete, but this error is thrown 
     and the return value of execute()/evalute() will be false/null.

2) However, if you believe that your application should execute as expected (in under10000 ms),
 then it might be a deadlock in SWT/Browser/webkit2 logic.
 I.e, it might be a bug in SWT (e.g this does not occur on Windows/Cocoa, but occurs on Linux). If you believe it to be a bug in SWT, then
Please report this issue *with steps to reproduce* via:
 https://bugs.eclipse.org/bugs/enter_bug.cgi?alias=&assigned_to=platform-swt-inbox%40eclipse.org&attach_text=&blocked=&bug_file_loc=http%3A%2F%2F&bug_severity=normal&bug_status=NEW&comment=&component=SWT&contenttypeentry=&contenttypemethod=autodetect&contenttypeselection=text%2Fplain&data=&defined_groups=1&dependson=&description=&flag_type-1=X&flag_type-11=X&flag_type-12=X&flag_type-13=X&flag_type-14=X&flag_type-15=X&flag_type-16=X&flag_type-2=X&flag_type-4=X&flag_type-6=X&flag_type-7=X&flag_type-8=X&form_name=enter_bug&keywords=&maketemplate=Remember%20values%20as%20bookmarkable%20template&op_sys=Linux&product=Platform&qa_contact=&rep_platform=PC&requestee_type-1=&requestee_type-2=&short_desc=webkit2_BrowserProblem
For bug report, please atatch this stack trace:
java.lang.Throwable: 
	at org.eclipse.swt.browser.WebKit.getStackTrace(WebKit.java:300)
	at org.eclipse.swt.browser.WebKit.getInternalErrorMsg(WebKit.java:293)
	at org.eclipse.swt.browser.WebKit$Webkit2AsyncToSync.execAsyncAndWaitForReturn(WebKit.java:1272)
	at org.eclipse.swt.browser.WebKit$Webkit2AsyncToSync.runjavascript(WebKit.java:1030)
	at org.eclipse.swt.browser.WebKit$Webkit2AsyncToSync.evaluate(WebKit.java:1000)
	at org.eclipse.swt.browser.WebKit.evaluate(WebKit.java:1299)
	at org.eclipse.swt.browser.WebBrowser.evaluate(WebBrowser.java:406)
	at org.eclipse.swt.browser.Browser.evaluate(Browser.java:665)
	at org.eclipse.swt.browser.Browser.evaluate(Browser.java:614)
	at org.eclipse.nebula.widgets.richtext.RichTextEditor$3.completed(RichTextEditor.java:284)
	at org.eclipse.swt.browser.WebKit.lambda$7(WebKit.java:1769)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:5040)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4520)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
	at org.polarsys.capella.core.platform.sirius.ui.app.CapellaApplication.start(CapellaApplication.java:118)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1440)

 Additional information about the error is as following:
 The following javascript was executed:
function SWTWebkit2TempFunc1(){initEditor();}; SWTWebkit2TempFunc1()

@acarstoiu
Copy link

Hate to bring bad news here, but webkit-gtk 2.44.1 produces crashes whenever a JSDoc pop-up should be displayed on Wayland 1.22 (GTK+ 3.24.41).

@mPorhel
Copy link

mPorhel commented Jul 5, 2024

Same situation with Eclipse 2024-06 and RichTextEditorSample from Nebula (master) on Ubuntu 22.04 and 24.04 (libwebkit2gtk-4.1-0:amd64 2.44.2-0ubuntu0.24.04.1 , ibgtk-3-0t64:amd64 3.24.41-4ubuntu1)

Eclipse Capella (7.0) is based on Eclipse 2023-03 with several customizations. But the issue can be reproduced with recent version of SWT, Eclipse, Nebula without the customization done by Capella and Kitalpha.

In Eclipse Capella, the same issue appears with the description editor, which uses the internal browser too.

@jamilraichouni
Copy link

jamilraichouni commented Jul 8, 2024

The Javascript code evaluation times out on Linux. It can easily be reproduced by spawning a Browser and asking it to evaluate some Javascript code.
I described it here: eclipse-capella/capella#2879 (comment) (also check my comment directly after the one I reference here). There is an information about the used SWT lib version.

@jamilraichouni
Copy link

jamilraichouni commented Jul 8, 2024

Hi @akurtakov ,

the SWT browser times out when one tries to pass any Javascript code to the .evaluate function in line 993 here:

static Object evaluate (String script, Browser browser, long webView) {

The problematic line is in runjavascript in line 1033 where we have a blocking (times out) call here:

Webkit2AsyncReturnObj retObj = execAsyncAndWaitForReturn(browser, asyncFunc, " The following javascript was executed:\n" + script +"\n\n");

When I modify this code and force a non blocking call like the following, it does not time out anymore but I'm afraid that it breaks the Java / Javascript bridge:

image

I have webkit2gtk4.1.aarch64 in version 2.44.2-2.fc40 (Fedora 40) and could try it with X11.

Does that help?

How do I check, if I really use this webkit lib my system package manager lists as installed? I ask, because I see .so files in the .jar I have in my classpath.

Does my template HTML I used in my debug code (next link) work to show the Webkit version? It is irritating that it shows the same version for my macOS host and Fedora Docker container although it works on the host and times out in the Fedora container.

I'd appreciate if you could read what I describe here: eclipse-capella/capella#2879 (comment)

@akurtakov
Copy link
Member

I have webkit2gtk4.1.aarch64 in version 2.44.2-2.fc40 (Fedora 40) and could try it with X11.

Does that help?

How do I check, if I really use this webkit lib my system package manager lists as installed? I ask, because I see .so files in the .jar I have in my classpath.

The *.so files in the jar are actually jni binding that call into the actual webkit2gtk libs you have installed on your system.

Does my template.html I used in my debug code work to show the Webkit version? It is irritating that it shows the same version for my macOS host and Fedora Docker container although it works on the host and times out in the Fedora container.

The version of webkit can be the same on mac and linux but you'll be using different ports (cocoa vs gtk) much like same Eclipse version on mac and linux will used completely different swt implementations (cocoa vs gtk) - and this comes with different bugs and/or features.

I'd appreciate if you could read what I describe here: eclipse-capella/capella#2879 (comment)

I have reproduced the issue on my side but unfortunately don't have the time to spend to investigate it more now. You would have to dig what happens on your on and if/when you have a PR ready I'll happily review it.

@jamilraichouni
Copy link

Okay, thanks @akurtakov !

I am not a Java developer, but I research a bit.

For others:

There is no timeout, when Java code lets the browser evaluate Javascript, but we have the timeout issue (deadlock), when Javascript calls a Java function which in turn asks the browser to execute Javascript.

image

@jamilraichouni
Copy link

What I described in my previous comment seems to be in line with what one can read in the first comment of this bug report:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=512001

The bug is referenced multiple times in bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java

@mPorhel
Copy link

mPorhel commented Jul 9, 2024

Hi @jamilraichouni @akurtakov,

In the situation where we get the timeout stack as reported by Jamil, the Javascript alert is shown so the Javascript is executed but the return value never obtained : org.eclipse.swt.browser.WebKit.Webkit2AsyncToSync.runjavascript_callback(long, long, long) is not called in those cases.
When we click on the button, here is the callback call stack

TestBrowser [Java Application]	
	TestBrowser at localhost:41907	
		Thread [main] (Suspended (breakpoint at line 1048 in WebKit$Webkit2AsyncToSync))	
			owns: RunnableLock  (id=55)	
**			WebKit$Webkit2AsyncToSync.runjavascript_callback(long, long, long) line: 1048	
**			GTK3.gtk_main_iteration_do(boolean) line: not available [native method]	
			WebKit$Webkit2AsyncToSync.execAsyncAndWaitForReturn(Browser, Consumer<Integer>, String) line: 1285	
			WebKit$Webkit2AsyncToSync.runjavascript(String, Browser, long) line: 1033	
			WebKit$Webkit2AsyncToSync.evaluate(String, Browser, long) line: 1003	
**			WebKit.evaluate(String) line: 1302	
			WebKit(WebBrowser).evaluate(String, boolean) line: 405	
			Browser.evaluate(String, boolean) line: 665	
			Browser.evaluate(String) line: 614	
			TestBrowser$JavaFunction$1.run() line: 84	
			RunnableLock.run(Display) line: 40	
			Synchronizer.runAsyncMessages(boolean) line: 132	
			Display.runAsyncMessages(boolean) line: 5040	
**			Display.readAndDispatch() line: 4520	
			TestBrowser.main(String[]) line: 25	
	/home/ubuntu/Downloads/eclipse-committers-2024-06-R-linux-gtk-aarch64/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.aarch64_21.0.3.v20240426-1530/jre/bin/java (Jul 9, 2024, 7:55:17 AM) [pid: 8458]	

WebKitGTK.webkit_web_view_run_javascript calls stacks

  • call from the JavaFunction (triggered by the "clic here" link in th sample case provided by Jamil )
Thread [main] (Suspended (breakpoint at line 1031 in WebKit$Webkit2AsyncToSync))	
	WebKit$Webkit2AsyncToSync.lambda$0(long, String, Integer) line: 1031	
	0x00000001001173f0.accept(Object) line: not available	
	WebKit$Webkit2AsyncToSync.execAsyncAndWaitForReturn(Browser, Consumer<Integer>, String) line: 1260	
	WebKit$Webkit2AsyncToSync.runjavascript(String, Browser, long) line: 1033	
	WebKit$Webkit2AsyncToSync.evaluate(String, Browser, long) line: 1003	
**	WebKit.evaluate(String) line: 1302
	WebKit(WebBrowser).evaluate(String, boolean) line: 405	
	Browser.evaluate(String, boolean) line: 665	
	Browser.evaluate(String) line: 614	
	TestBrowser$JavaFunction.function(Object[]) line: 80	
	WebKit.RequestProc(long, long) line: 461	
**	GTK3.gtk_main_iteration_do(boolean) line: not available [native method]
**	Display.readAndDispatch() line: 4514	
	TestBrowser.main(String[]) line: 25	
  • call when the evaluation is triggered from the SWTButton in the sample case provided by Jamil:
Thread [main] (Suspended (breakpoint at line 1031 in WebKit$Webkit2AsyncToSync))	
	WebKit$Webkit2AsyncToSync.lambda$0(long, String, Integer) line: 1031	
	0x00000001001173f0.accept(Object) line: not available	
	WebKit$Webkit2AsyncToSync.execAsyncAndWaitForReturn(Browser, Consumer<Integer>, String) line: 1260	
	WebKit$Webkit2AsyncToSync.runjavascript(String, Browser, long) line: 1033	
	WebKit$Webkit2AsyncToSync.evaluate(String, Browser, long) line: 1003	
**	WebKit.evaluate(String) line: 1302	
	WebKit(WebBrowser).evaluate(String, boolean) line: 405	
	Browser.evaluate(String, boolean) line: 665	
	Browser.evaluate(String) line: 614	
	TestBrowser$JavaFunction.function(Object[]) line: 80	
	WebKit.RequestProc(long, long) line: 461	
**	GTK3.gtk_main_iteration_do(boolean) line: not available [native method]	
**	Display.readAndDispatch() line: 4514	
	TestBrowser.main(String[]) line: 25	

I have also noticed that Webkit 2.40 the API used in org.eclipse.swt.browser.WebKit.Webkit2AsyncToSync::runjavascript/execAsyncAndWaitForReturn have been marked as deprecated: 2 methods linked via org.eclipse.swt.internal.webkit.WebKitGTK might need to be adapted:

  • webkit_web_view_run_javascript(long, byte[], long, long, long)
    • Deprecated since: 2.40
    • Use webkit_web_view_evaluate_javascript() instead.
  • webkit_web_view_run_javascript_finish(long, long, long [])
    • Deprecated since: 2.40
    • Use webkit_web_view_evaluate_javascript_finish() instead.

I wonder if/how we might try to use the replacement methods to see if WebKit behavior has changed.

I checked the behavior on macOs, both scenarios from the sample behave well, in the same way using the org.eclipse.swt.browser.WebBrowser::evaluate/nonBlockingExecute methods. The Java callback is well called in both cases.
In SWT GTK implementation this is overriden with call to org.eclipse.swt.browser.WebKit.Webkit2AsyncToSync.evaluate(String, Browser, long) which calls org.eclipse.swt.internal.gtk3.GTK3.gtk_main_iteration_do(true) in a loop.

@iloveeclipse
Copy link
Member

I wonder if/how we might try to use the replacement methods to see if WebKit behavior has changed.

Feel free to provide a patch for testing that, contribution is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux/GTK Happens on Linux Webkit
Projects
None yet
Development

No branches or pull requests