Bug 546061 - No more handles exception or UI blinking when using SWT_AWT on GTK3
Summary: No more handles exception or UI blinking when using SWT_AWT on GTK3
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.10   Edit
Hardware: PC CentOS
: P3 normal (vote)
Target Milestone: 4.11   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-04-02 11:01 EDT by Alexander Zakusylo CLA
Modified: 2019-04-24 10:31 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Zakusylo CLA 2019-04-02 11:01:27 EDT
Create an RCP application with a view embedding some Swing UI:

public class View extends ViewPart {
	
	public static final String ID = "TestFxPlugin.view";

	@Override
	public void createPartControl(Composite parent) {
		Composite swingBox = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
        java.awt.Frame frame = SWT_AWT.new_Frame(swingBox);
        frame.setLayout(new FlowLayout()); 
        JComboBox<String> btn = new JComboBox<>();
    	btn.setToolTipText("Toolip");
    	btn.addItem("Click me");
    	frame.add(btn, java.awt.BorderLayout.CENTER);
	}


	@Override
	public void setFocus() {
	}	
}

Run on Linux with GTK3 and click the combo box.

I get a GDK error message followed by an exception:


(SWT:30007): Gdk-CRITICAL **: 17:35:25.356: The window 0x7effe543ec80 already has a drawing context. You cannot call gdk_window_begin_draw_frame() without calling gdk_window_end_draw_frame() first.


!ENTRY org.eclipse.ui 4 0 2019-04-02 17:35:25.385
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTError: No more handles
	at org.eclipse.swt.SWT.error(SWT.java:4621)
	at org.eclipse.swt.SWT.error(SWT.java:4510)
	at org.eclipse.swt.SWT.error(SWT.java:4481)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:526)
	at org.eclipse.swt.widgets.Control.drawBackground(Control.java:208)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:6285)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5880)
	at org.eclipse.swt.internal.gtk.GTK._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.GTK.gtk_main_do_event(GTK.java:3969)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1385)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1581)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4470)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:563)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:151)
	at testfxplugin.Application.start(Application.java:18)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	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:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1501)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1474)


In our real complex application the exception is not seen, but UI starts flickering. The symptoms look very similar to those described for https://bugs.eclipse.org/bugs/show_bug.cgi?id=542675 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=517671, but the suggested workaround (setting GTK_IM_MODULE to ibus/blank) does not work.

The bug is always reproducible with the above snippet on CentOS 7.3
Comment 1 Eric Williams CLA 2019-04-02 11:39:06 EDT
Does the issue reproduce with 4.10, i.e. is this a regression?
Comment 2 Alexander Zakusylo CLA 2019-04-03 05:09:41 EDT
Looks like it's fixed in the latest release:

Not reproducible with 4.6 (with SWT_GTK3=1)
Reproducible with 4.10
Not reproducible with 4.11
Comment 3 Eric Williams CLA 2019-04-03 08:14:07 EDT
I don't think we can set RESOLVED here because a specific fix isn't referenced in the bug. Usually I just mark these as WORKSFORME.
Comment 4 Phil Pemberton CLA 2019-04-24 07:43:28 EDT
There's an easy way to reproduce this.

If $GTK_IM_MODULE is set to "xim", Eclipse will repeatably crash in this manner.

I have a wrapper script which fixes this then starts Eclipse:

    #!/bin/bash
    
    # PP: Fix for ibus, from https://wiki.archlinux.org/index.php/IBus
    #     Fixes issues with Eclipse crashing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=517671
    # PP: Better fix from https://wiki.debian.org/I18n/ibus - run "im-config -n ibus"  -- NOTE doesn't fecking work, ffs, thank you dbus-update-activation-environment
    export GTK_IM_MODULE=ibus
    export XMODIFIERS=@im=ibus
    export QT_IM_MODULE=ibus
    
    $HOME/APPS/eclipse/eclipse
Comment 5 Eric Williams CLA 2019-04-24 08:44:56 EDT
(In reply to Phil Pemberton from comment #4)
> There's an easy way to reproduce this.
> 
> If $GTK_IM_MODULE is set to "xim", Eclipse will repeatably crash in this
> manner.
> 
> I have a wrapper script which fixes this then starts Eclipse:
> 
>     #!/bin/bash
>     
>     # PP: Fix for ibus, from https://wiki.archlinux.org/index.php/IBus
>     #     Fixes issues with Eclipse crashing, see
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=517671
>     # PP: Better fix from https://wiki.debian.org/I18n/ibus - run "im-config
> -n ibus"  -- NOTE doesn't fecking work, ffs, thank you
> dbus-update-activation-environment
>     export GTK_IM_MODULE=ibus
>     export XMODIFIERS=@im=ibus
>     export QT_IM_MODULE=ibus
>     
>     $HOME/APPS/eclipse/eclipse

This is documented, there should be a warning printed when SWT is run with the "xim" input module specified.
Comment 6 Phil Pemberton CLA 2019-04-24 10:31:34 EDT
(In reply to Eric Williams from comment #5)
> This is documented, there should be a warning printed when SWT is run with
> the "xim" input module specified.

I'm currently running this version of Eclipse and don't get a warning about the "xim" input module:

Eclipse IDE for Java Developers
Version: 2019-03 (4.11.0)
Build id: 20190314-1200
OS: Linux, v.4.15.0-47-generic, x86_64 / gtk 3.22.30
Java version: 11.0.2

Was this added in a later version?