Re: NewtCanvasSWT Linux Exception with GTK_VERSION
Posted by Wade Walker on Feb 10, 2019; 4:09pm
URL: https://forum.jogamp.org/NewtCanvasSWT-Linux-Exception-with-GTK-VERSION-tp4039442p4039503.html
This bug may require Sven to do a fix. To summarize the work so far:
- When users try to use JOGL with GTK 3, they get an exception when JOGL tries to read GTK_VERSION from org.eclipse.swt.internal.gtk.OS (its location in GTK 2)
- If you fix JOGL to read GTK_VERSION from its new location in org.eclipse.swt.internal.gtk.GTK (where it moved in GTK 3), then you get another problem:
(SWT:14860): Gdk-CRITICAL **: 17:47:49.569: The window 0x7f71e51ac640 already has a drawing context. You cannot call gdk_window_begin_draw_frame() without calling gdk_window_end_draw_frame() first.
(SWT:14860): Gdk-CRITICAL **: 17:47:49.569: gdk_drawing_context_get_cairo_context: assertion 'GDK_IS_DRAWING_CONTEXT (context)' failed
org.eclipse.swt.SWTError: No more handles
- The problem shows up in JOGL unit tests like com.jogamp.opengl.test.junit.jogl.swt.preAttach_NoAnimator()
- The problem seems to be caused by a significant change to the way drawing works between GTK 2 and GTK 3. Somehow the NewtCanvasSWT is skipping a gdk_window_end_draw_frame() somewhere. But JOGL never directly calls gdk_window_begin_draw_frame(), gdk_window_end_draw_frame(), or gdk_drawing_context_get_cairo_context(), and it's never erroneously disposing a Cairo context, so I don't know how this could be happening.
- The problem doesn't occur if you step through the code slowly in the debugger, seemingly because it can't switch frames fast enough to run out of contexts before the test ends. The gdk_window_begin_draw_frame()/gdk_window_end_draw_frame() calls are always properly paired when you set breakpoints on them.
Next I'll try running the test for a longer time in the debugger, to see if I can make it fail after more cycles, but it's not looking promising. If anyone else wants to give this a try, I can give you the GTK 3 patch that I've written so far.