eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
111 stars 127 forks source link

Eclipse/Webkit browser crashes on Linux #843

Open Phillipus opened 10 months ago

Phillipus commented 10 months ago

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:

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
      • [x] Linux
      • [ ] macOS
  2. 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 commented 10 months ago

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 commented 10 months ago

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:

iloveeclipse commented 10 months ago

And which webkit is loaded by SWT?

akurtakov commented 10 months ago

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 (https://github.com/eclipse-platform/eclipse.platform.swt/blob/459daddd8d72b22437dd88a956ea31feccb45ff0/bundles/org.eclipse.swt/Eclipse%20SWT%20WebKit/gtk/library/webkitgtk.h#L48) which may no longer be in the same shape as libwebkit2gtk-4.1. For what it works - Fedora drops 4.0 already.

Phillipus commented 10 months ago

How do I get the specific versions?

iloveeclipse commented 10 months ago

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

akurtakov commented 10 months ago

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

Phillipus commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 9 months ago

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 commented 9 months ago

@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 commented 9 months ago

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 commented 7 months ago

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 commented 7 months ago

@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 https://github.com/eclipse-platform/eclipse.platform.swt/commit/4d1d26a8d9347a8d379819887464eca83ab39023 .

iloveeclipse commented 7 months ago

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 commented 7 months ago

@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 commented 7 months ago

@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 commented 7 months ago

@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 commented 7 months ago

@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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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

akurtakov commented 4 months ago

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

realDragon11 commented 4 months ago

After installing that build as a software site, Eclipse seemingly got stuck in an infinite loading screen when loading older workspaces. Upon creating a new one, Tip of the Day still crashed instantly on opening without the environment variable, so I don't think the workaround works. The environment variable still prevents the crash. (For me that was WEBKIT_DISABLE_DMABUF_RENDERER=1)

huw0 commented 4 months ago

I've upgraded to 2024-03 today and I'm seeing coredumps whenever libweb2gtk is involved, seemingly 100% of the time. Fedora 39 webkit2gtk4.1-2.44.0-2.fc39.x86_64

The WEBKIT_DISABLE_DMABUF_RENDERER=1 workaround resolves the issue. Eclipse is unusable without this.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fef803ba130, pid=37762, tid=37763
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.10+7 (17.0.10+7) (build 17.0.10+7)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (17.0.10+7, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libwebkit2gtk-4.1.so.0+0xdba130]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/user/core.37762)
#
# If you would like to submit a bug report, please visit:
#   https://github.com/adoptium/adoptium-support/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  S U M M A R Y ------------

Command Line: -Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclientjava -Dosgi.requiredJavaVersion=17 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Declipse.e4.inject.javax.warning=false -Xms1024m -Xmx4096m -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Djava.security.manager=allow /home/user/eclipse//plugins/org.eclipse.equinox.launcher_1.6.700.v20240213-1244.jar -os linux -ws gtk -arch x86_64 -showsplash /home/user/eclipse//plugins/org.eclipse.epp.package.common_4.31.0.20240307-1200/splash.bmp -launcher /home/user/eclipse/eclipse -name Eclipse --launcher.library /home/user/eclipse//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.900.v20240129-1338/eclipse_11900.so -startup /home/user/eclipse//plugins/org.eclipse.equinox.launcher_1.6.700.v20240213-1244.jar --launcher.appendVmargs -exitdata 18008 -product org.eclipse.epp.package.jee.product -data file:/media/storage/user-redir/eclipse-workspace/ -vm /home/user/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_17.0.10.v20240120-1143/jre/bin/java -vmargs -Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclientjava -Dosgi.requiredJavaVersion=17 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Declipse.e4.inject.javax.warning=false -Dsun.java.command=Eclipse -Xms1024m -Xmx4096m -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Djava.security.manager=allow -jar /home/user/eclipse//plugins/org.eclipse.equinox.launcher_1.6.700.v20240213-1244.jar

Host: AMD Ryzen 9 7950X3D 16-Core Processor, 32 cores, 125G, Fedora release 39 (Thirty Nine)
Time: Tue Apr  2 13:52:11 2024 BST elapsed time: 536.306741 seconds (0d 0h 8m 56s)

---------------  T H R E A D  ---------------

Current thread (0x00007ff49c027620):  JavaThread "main" [_thread_in_native, id=37763, stack(0x00007ff4a2b00000,0x00007ff4a2c00000)]

Stack: [0x00007ff4a2b00000,0x00007ff4a2c00000],  sp=0x00007ff4a2bfcdd0,  free space=1011k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libwebkit2gtk-4.1.so.0+0xdba130]
C  [libwebkit2gtk-4.1.so.0+0xdba270]
C  [libwebkit2gtk-4.1.so.0+0xb2d279]
C  [libwebkit2gtk-4.1.so.0+0xbf7dd2]
C  [libwebkit2gtk-4.1.so.0+0xb24ec5]
C  [libwebkit2gtk-4.1.so.0+0xb26f9b]
C  [libjavascriptcoregtk-4.1.so.0+0x16fc195]
C  [libjavascriptcoregtk-4.1.so.0+0x175a83d]
C  [libjavascriptcoregtk-4.1.so.0+0x175b23d]
C  [libglib-2.0.so.0+0x5be5c]
C  [libglib-2.0.so.0+0xb6f18]
C  [libglib-2.0.so.0+0x59ad3]  g_main_context_iteration+0x33
C  [libgtk-3.so.0+0x206c8d]  gtk_main_iteration_do+0x1d
C  [libswt-pi3-gtk-4964r8.so+0x5563c]  Java_org_eclipse_swt_internal_gtk3_GTK3_gtk_1main_1iteration_1do+0xc

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 12213  org.eclipse.swt.internal.gtk3.GTK3.gtk_main_iteration_do(Z)Z (0 bytes) @ 0x00007ff491b41669 [0x00007ff491b41620+0x0000000000000049]
J 23876 c2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (88 bytes) @ 0x00007ff491f450a0 [0x00007ff491f44fc0+0x00000000000000e0]
j  org.eclipse.jface.internal.text.html.BrowserInformationControl.setVisible(Z)V+58
j  org.eclipse.jface.text.AbstractInformationControlManager.showInformationControl(Lorg/eclipse/swt/graphics/Rectangle;)V+5
j  org.eclipse.jface.text.TextViewerHoverManager.showInformationControl(Lorg/eclipse/swt/graphics/Rectangle;)V+21
j  org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(Lorg/eclipse/swt/graphics/Rectangle;Ljava/lang/Object;)V+344
j  org.eclipse.jface.text.AbstractInformationControlManager.presentInformation()V+70
j  org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation()V+64
j  org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation()V+1
j  org.eclipse.jface.text.TextViewerHoverManager.lambda$3(Lorg/eclipse/swt/custom/StyledText;)V+8
j  org.eclipse.jface.text.TextViewerHoverManager$$Lambda$2719+0x000000080138e838.run()V+8
J 22072 c2 org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Z)Z (188 bytes) @ 0x00007ff4924d7e0c [0x00007ff4924d7920+0x00000000000004ec]
J 23876 c2 org.eclipse.swt.widgets.Display.readAndDispatch()Z (88 bytes) @ 0x00007ff491f450dc [0x00007ff491f44fc0+0x000000000000011c]
J 26875% c1 org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run()V (690 bytes) @ 0x00007ff48c1acedc [0x00007ff48c1a7880+0x000000000000565c]
j  org.eclipse.core.databinding.observable.Realm.runWithDefault(Lorg/eclipse/core/databinding/observable/Realm;Ljava/lang/Runnable;)V+12
j  org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(Lorg/eclipse/e4/ui/model/application/MApplicationElement;Lorg/eclipse/e4/core/contexts/IEclipseContext;)Ljava/lang/Object;+57
j  org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(Lorg/eclipse/e4/ui/model/application/MApplicationElement;)V+20
j  org.eclipse.ui.internal.Workbench.lambda$3(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;[I)V+392
j  org.eclipse.ui.internal.Workbench$$Lambda$296+0x00000008003074e0.run()V+12
j  org.eclipse.core.databinding.observable.Realm.runWithDefault(Lorg/eclipse/core/databinding/observable/Realm;Ljava/lang/Runnable;)V+12
j  org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+16
j  org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
j  org.eclipse.ui.internal.ide.application.IDEApplication.start(Lorg/eclipse/equinox/app/IApplicationContext;)Ljava/lang/Object;+113
j  org.eclipse.equinox.internal.app.EclipseAppHandle.run(Ljava/lang/Object;)Ljava/lang/Object;+138
j  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Ljava/lang/Object;)Ljava/lang/Object;+85
j  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ljava/lang/Object;)Ljava/lang/Object;+79
j  org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+99
j  org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+132
v  ~StubRoutines::call_stub
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base@17.0.10
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+133 java.base@17.0.10
j  jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6 java.base@17.0.10
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+59 java.base@17.0.10
j  org.eclipse.equinox.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+202
j  org.eclipse.equinox.launcher.Main.basicRun([Ljava/lang/String;)V+159
j  org.eclipse.equinox.launcher.Main.run([Ljava/lang/String;)I+4
j  org.eclipse.equinox.launcher.Main.main([Ljava/lang/String;)V+10
v  ~StubRoutines::call_stub
MoritzWeber0 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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: https://github.com/eclipse-capella/capella/issues/2879#issuecomment-2212550507 (also check my comment directly after the one I reference here). There is an information about the used SWT lib version.

jamilraichouni commented 1 month ago

Hi @akurtakov ,

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

https://github.com/eclipse-platform/eclipse.platform.swt/blob/d95a44426efe0ac44f01874638707b2634218e7c/bundles/org.eclipse.swt/Eclipse%20SWT%20WebKit/gtk/org/eclipse/swt/browser/WebKit.java#L993

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

https://github.com/eclipse-platform/eclipse.platform.swt/blob/d95a44426efe0ac44f01874638707b2634218e7c/bundles/org.eclipse.swt/Eclipse%20SWT%20WebKit/gtk/org/eclipse/swt/browser/WebKit.java#L1033

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: https://github.com/eclipse-capella/capella/issues/2879#issuecomment-2212550507

akurtakov commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

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:

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 commented 1 month ago

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.