Open MoritzWeber0 opened 2 weeks ago
I tried both workarounds with environment variables described in https://github.com/eclipse-platform/eclipse.platform.swt/issues/843.
Neither WEBKIT_DISABLE_COMPOSITING_MODE=1
nor WEBKIT_DISABLE_DMABUF_RENDERER=1
have worked for me.
Hello
I tried with Ubuntu 22.04.4 as windows11 sub system and I reproduced the issue.
I reproduced with and wihtout WEBKIT_DISABLE_COMPOSITING_MODE=1
nor WEBKIT_DISABLE_DMABUF_RENDERER=1
Nevertheless, I did not get completely freezes but get the Webkit time out of 10000ms.
I also get first this error
libEGL warning: MESA-LOADER: failed to open vgem: /usr/lib/dri/vgem_dri.so: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce nom (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
It probably comes from a not proper ubuntu installation using wsl.
So to eliminate this additional context problem. I tested with virtualbox with unbuntu 24.04 This time I also did reproduced but did not get the same errors. I only got warning
!ENTRY org.polarsys.kitalpha.richtext.widget 2 0 2024-07-02 17:01:32.620
!MESSAGE Rich text widget can not install beforePaste/afterPaste/beforeCommandExec listeners!
!ENTRY org.polarsys.kitalpha.richtext.widget 2 0 2024-07-02 17:01:32.626
!MESSAGE Rich text widget cannot install the open link command
...
Those warning are about java call back that are called when doing things in the CKEditor At this stage, I have no idea of where the issue is located.
I reproduce the issue and the stack trace with ubuntu 24.04.4 in a virtualbox
When the RichTextEditor initializes
Thread [main] (Suspended (breakpoint at line 1761 in WebKit))
WebKit.fireProgressCompletedEvent() line: 1761
WebKit.webkit_load_changed(long, int, long) line: 2359
WebKit.webViewProc(long, long, long) line: 605
WebKit.Proc(long, long, long) line: 529
GTK3.gtk_main_iteration_do(boolean) line: not available [native method]
Display.readAndDispatch() line: 4514
...
private void fireProgressCompletedEvent(){
Runnable fireProgressEvents = () -> {
if (browser.isDisposed() || progressListeners == null) return;
ProgressEvent progress = new ProgressEvent (browser);
progress.display = browser.getDisplay ();
progress.widget = browser;
progress.current = MAX_PROGRESS;
progress.total = MAX_PROGRESS;
for (int i = 0; i < progressListeners.length; i++) {
progressListeners[i].completed (progress);
}
};
browser.getDisplay().asyncExec(fireProgressEvents);
}
There are two progressListeners
called in the for loop:
/org.eclipse.nebula.widgets.richtext/src/org/eclipse/nebula/widgets/richtext/RichTextEditor.java
org.polarsys.kitalpha.richtext.nebula.widget.MDENebulaBasedRichTextWidgetImpl
In /org.eclipse.nebula.widgets.richtext/src/org/eclipse/nebula/widgets/richtext/RichTextEditor.java
this.browser.addProgressListener(new ProgressListener() {
@Override
public void completed(ProgressEvent event) {
browser.evaluate("initEditor();");
This method fails. So something gets wrong in initEditor()
initEditor()
is defined in /org.eclipse.nebula.widgets.richtext/src/org/eclipse/nebula/widgets/richtext/resources/template.html
Edit:
It turns out initEditor
calls customizeToolbar
which calls the java method org.eclipse.nebula.widgets.richtext.RichTextEditorConfiguration.getCustomButtonConfiguration()
that will cause evaluation error.
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.RichTextEditorConfiguration.customizeToolbar(RichTextEditorConfiguration.java:613)
And then browser.evaluate("initEditor();");
will end up with similar stack trace.
Why? I do not know so far.
The executed script is : CKEDITOR.instances.editor.addCommand('openEditor', { exec: function (edt) { javaExecutionStarted(); openEditor(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('openEditor', { label: 'Open in Editor', command: 'openEditor', toolbar: 'enableEdit', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget/icons/openInEditor.gif', }); CKEDITOR.instances.editor.addCommand('MDESave', { exec: function (edt) { javaExecutionStarted(); MDESave(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('MDESave', { label: 'Save editor', command: 'MDESave', toolbar: 'mdesave', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget.tools/icons/save_image.gif', }); CKEDITOR.instances.editor.addCommand('Refresh', { exec: function (edt) { javaExecutionStarted(); Refresh(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('Refresh', { label: 'Refresh editor', command: 'Refresh', toolbar: 'Refresh', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget.tools/icons/refresh.gif', }); CKEDITOR.instances.editor.addCommand('MDESave', { exec: function (edt) { javaExecutionStarted(); MDESave(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('MDESave', { label: 'Save editor content', command: 'MDESave', toolbar: 'mdesave', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget.tools/icons/save_image.gif', }); CKEDITOR.instances.editor.addCommand('Refresh', { exec: function (edt) { javaExecutionStarted(); Refresh(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('Refresh', { label: 'Refresh editor', command: 'Refresh', toolbar: 'Refresh', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget.tools/icons/refresh.gif', }); CKEDITOR.instances.editor.addCommand('Clean', { exec: function (edt) { javaExecutionStarted(); Clean(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('Clean', { label: 'Clean', command: 'Clean', toolbar: 'clean', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget.tools/icons/clear.gif', }); CKEDITOR.instances.editor.addCommand('Addlink', { exec: function (edt) { javaExecutionStarted(); Addlink(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('Addlink', { label: 'Link', command: 'Addlink', toolbar: 'mdelinks', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget.tools/icons/add_link.gif', }); CKEDITOR.instances.editor.addCommand('AddImage', { exec: function (edt) { javaExecutionStarted(); AddImage(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('AddImage', { label: 'Add Image', command: 'AddImage', toolbar: 'mdelinks', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/_TP/2023_03_cdo422/../../_git/kitalpha/richtext/plugins/org.polarsys.kitalpha.richtext.widget.tools/icons/add_image.gif', }); CKEDITOR.instances.editor.addCommand('OpenInEditor', { exec: function (edt) { javaExecutionStarted(); OpenInEditor(); javaExecutionFinished() } }); CKEDITOR.instances.editor.ui.addButton('OpenInEditor', { label: 'Open in Editor', command: 'OpenInEditor', toolbar: 'enableEdit', icon: 'file:/home/laurent/DEV/_eclipse/dev-2023-03/eclipse-workspace/.metadata/.plugins/org.eclipse.pde.core/T4C/org.eclipse.osgi/1130/0/.cp/icons/full/obj16/open_in_editor.gif', });
Good luck to know what wrong happened there :/
Hey @lfasani,
thanks for the detailed investigation, appreciate it!
The warnings (Rich text widget can not install * listeners
) exist for a long time already and were also printed in Capella 6.0.0. I'm not sure how they are related to the actual issue.
I think that the JavaScript timeout is responsible for the freezes.
It's interesting that you don't see the freezes in your installation (We have reproduced it on debian, fedora and ArchLinux). Maybe it's related to specific versions of other dependencies. But hard to figure out which dependency is responsible for it. Which versions of libwebkitgtk do you installed in your VM?
I'll try to run Capella against webkit2gtk-4.1 instead of libwebkit2gtk-4.0-37 (Probably needs this commit https://github.com/eclipse-platform/eclipse.platform.swt/commit/4d1d26a8d9347a8d379819887464eca83ab39023 tho).
Hello To clarify, I did get the javascript timeout of 10s but, after that, the Capella is still usable (the Capella is not freezed).
To complete the analysis in my previous comment, I tried to understand what was problematic in the script(I supposed for example that CKEDITOR.instances.editor.addCommand
was undefined), I manually changed the injected JavaScript in org.eclipse.nebula.widgets.richtext.RichTextEditorConfiguration
and I ended up figuring out that just the script console.log('hello')
will make the evaluation fail. I have no clue why this simple instruction make the evaluation fail.
So I have no lead to progress except debugging the CKEditor JavaScript.
Otherwise, Capella is using libwebkit2gtk-4.1-0:amd64 2.44.2-0ubuntu0.24.04.1
Thanks for the clarification, then we are on the same line. My Capella is also usable again after 10 seconds, but I'd still consider that as not really usable if I have to wait 10 seconds after each keystroke.
Some users have reported that newer commits in eclipse.platform.swt fixed the issue. Can we get a Capella build which includes the latest version of eclipse.platform.swt to try it out?
As another workaround, is it maybe possible to reduce the timeout to a really low value to reduce the long freeze time? If possible, we should set it to a value of 100ms. https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20WebKit/gtk/org/eclipse/swt/browser/WebKit.java#n117
Reducing the timeout will get you nowhere. Because, under the hood, the problem is that the scripts are not executed and so the java callback that do the link between the Capella model and the CKEditor is broken. In concrete terms, getText() and setText() are not called so the description in the Capella model can be read not saved. So the editor is just a blank board connected to nothing.
Hi Moritz,
Eclipse Capella 7.0 is built on top of Eclipse 2023-03.
I have just tried to launch the Nebula RichTextEditor sample from a fresh Eclipse 2024-06 on Ubuntu 22.04, I get the same initialization error.
org.eclipse.swt.gtk.linux.aarch64_3.126.0.v20240528-0813.jar:
It contains the patch you mention.
Hi Moritz,
Eclipse Capella 7.0 is built on top of Eclipse 2023-03.
I have just tried to launch the Nebula RichTextEditor sample from a fresh Eclipse 2024-06 on Ubuntu 22.04, I get the same initialization error.
org.eclipse.swt.gtk.linux.aarch64_3.126.0.v20240528-0813.jar:
- Eclipse-SourceReferences: scm:git:https://github.com/eclipse-platform/eclipse.platform.swt.git;path="binaries/org.eclipse.swt.gtk.linux.aarch64 ";tag="I20240528-0600";commitId=2acc685a7d42efaf2f494ac4445d6eb4f7e7261 b
It contains the patch you mention.
Thanks for trying out. Can you try the new version with the variables WEBKIT_DISABLE_COMPOSITING_MODE=1
and WEBKIT_DISABLE_DMABUF_RENDERER=1
?
My test was done with and without those variables. Same situation on 22.04 and on 24.04 from @lfasani
Hi @mPorhel, can you share stdout/ stderr, please?
Hi @lfasani , hi @mPorhel,
The problem is independent from the classes defined in the org.eclipse.nebula.widgets.richtext
package and can be reproduced without any richtext widget.
The RichtextEditor widget in Capella fails, because the method .evaluate()
of the org.eclipse.swt.browser.Browser
refuses to execute Javascript code as @lfasani already figured out.
The RichTextEditor tries that in this line 233:
which in turn calls a Java method which is located in line 612 here:
Whatever non-empty Javascript string we pass to browser.evaluate()
, it will time out after 10 seconds.
One can demonstrate that wihout the Richtext widget:
TestBrowser.java
:
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.BrowserFunction;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.SelectionEvent;
import java.io.File;
public class TestBrowser extends Composite {
Browser browser;
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display, SWT.MIN | SWT.CLOSE);
shell.setText("SWT Browser test");
shell.setSize(500, 400);
shell.setLayout(new FillLayout());
TestBrowser testWindow = new TestBrowser(shell);
testWindow.createBrowser();
shell.open();
while (!display.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
int y = 0;
TestBrowser(Shell shell) {
super(shell, SWT.BORDER);
this.setSize(400, 400);
Button button = new Button(this, SWT.PUSH);
button.setText("Create a browser");
button.setLocation(200, 250);
button.pack();
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
@Override
public void widgetSelected(SelectionEvent arg0) {
createBrowser();
}
});
}
public void createBrowser() {
System.out.println("\nCreate a new browser");
browser = new Browser(this, SWT.BORDER);
browser.setSize(400, 200);
browser.setLocation(0, y);
File htmlFile;
htmlFile = new File("test.html");
browser.setUrl(htmlFile.getAbsolutePath());
final BrowserFunction brf = new JavaFunction(browser, "callJavaFunction");
y = y + 200;
}
private class JavaFunction extends BrowserFunction {
String name;
JavaFunction(Browser browser, String name) {
super(browser, name);
this.name = name;
}
@Override
public Object function(Object[] arguments) {
System.out.println("Java called from Javascript");
if (name.equals("callJavaFunction")) {
System.out.println("function callJava with argument : " + arguments[0]);
}
browser.evaluate("var a = 1;");
System.out.println("SUCCESS!");
return null;
}
}
}
test.html
:
<html>
<head>
<script type="text/javascript">
function hello(msg) {
try {
callJavaFunction(msg);
} catch (e) {
alert(e.message);
}
}
</script>
</head>
<body>
<h1>WebKit Version</h1>
<p id="userAgent"></p>
<script>
document.getElementById('userAgent').innerText = navigator.userAgent;
</script>
<a href="javascript:hello('link clicked')">click here</a>
</body>
</html>
This code executes just fine and opens the following window in a Fedora Docker container on an aarch64 macOS:
When one clicks on the link labelled as "click here", we get (after waiting the 10 seconds) the same timeout message:
The same isolated SWT browser code which tries to execute some Javascript runs without a failure/ timeout on macOS (aarch64):
In both cases (Linux and macOS) I have put the SWT libs from capella/plugins of the Capella 7.0.0-S20240619 downloads ( https://download.eclipse.org/capella/core/products/stable/7.0.0-S20240619/) to the classpath:
org.eclipse.swt_3.123.0.v20230220-1431.jar
and
org.eclipse.swt.gtk.linux.aarch64_3.123.0.v20230220-1431.jar
respectively
org.eclipse.swt.cocoa.macosx.aarch64_3.123.0.v20230220-1431.jar
Hi @jamilraichouni,
I got the same errors/stacks than Laurent, Moritz and you.
Hi @jamilraichouni
I have run your TestBrowser snippet with eclipse-committers-2024-06-R-linux-gtk-aarch6 with org.eclipse.swt_3.126.0.v20240528-0813.jar and org.eclipse.swt.gtk.linux.aarch64_3.126.0.v20240528-0813.jar I get exactly the same behavior/logs than you with Capella 7 (Eclipse 2023-03).
Hi @jamilraichouni
In parallel to the discussion in the Eclipse/Webkit browser issue, I am testing a second approach to avoid the observed deadlock with a few workraounds directly inside Capella/Kitalpha's Richtext configuration, functions and helpers for the Webkit/gtk case.
I currently have some interesting results.
In the latest pre-release of Capella 7.0.0, the description editor / richtext editor is completely unusable. Whenever I start typing, Capella freezes completely.
Steps to reproduce
I can also provide a Docker image to reproduce. Let me know if that would help.
Stacktrace
I've tried several different webkit2gtk versions, also different distributions (Alpine, Fedora & Debian). I could reproduce the issue in all cases.
The issue seems to be different to the other reported issues affecting Capella versions < 7.0.0 on Linux: https://github.com/eclipse-capella/capella/issues/2316