xpra icon
Bug tracker and wiki

Opened 3 years ago

Closed 3 months ago

Last modified 2 months ago

#640 closed task (fixed)

Python3 GTK3 client feature parity

Reported by: Antoine Martin Owned by: Antoine Martin
Priority: major Milestone: 2.1
Component: platforms Version: trunk
Keywords: gtk3 Cc:

Description (last modified by Antoine Martin)

Split from #90, remaining items so that this port can be used in place of the current GTK2 version:

  • OpenGL support (so painting the screen won't be so agonizingly slow)
  • clipboard support: GTK3 Clipboard
  • pycrypto fastmath #373
  • CTRL_C needs an event to exit main loop, force one?
  • launcher
  • mouse cursors support

Lower priority:

  • the win32 cx_freeze installer could be trimmed down further (low priority) - ie: for opengl, see the osx changes in r7326 (those could also go into gtk2 builds)
  • fix transparency with cairo (or just use OpenGL)
  • fix webp
  • session info statistics are missing (string vs bytes nonsense), graphs need rewriting using cairo (oh joy)
  • XSETTINGS and root property support
  • packaging: use separate RPMs?
  • add --max-size option (see #263 for GTK2)
  • maybe GTK3 will allow us to deal with grabs and application-modal windows?

Attachments (7)

gtk3-gl-v4.patch (67.9 KB) - added by Antoine Martin 3 years ago.
work in progress patch for gtk3 + opengl support
gtk3-gl-v8.patch (73.7 KB) - added by Antoine Martin 3 years ago.
dirty patch which sort of works if you ignore the stream of stacktraces!
gtk3-gl-v10.patch (82.8 KB) - added by Antoine Martin 3 years ago.
working patch which breaks gtk2... so close!
gtk3-gl-v11.patch (79.0 KB) - added by Antoine Martin 3 years ago.
working patch! just needs swap_buffers and packaging workaound for win32
gtk3-gl-v13.patch (79.2 KB) - added by Antoine Martin 3 years ago.
cleaner version that works with single buffering only
gtk3-win32-cursors.patch (4.7 KB) - added by Antoine Martin 3 years ago.
some work in progress to try to support cursors on win32 using cairo (requires gtk 3.10)
bencode-work9.patch (15.0 KB) - added by Antoine Martin 2 years ago.
work in progress patch - fixes bencode for py3k

Download all attachments as: .zip

Change History (53)

comment:1 Changed 3 years ago by Antoine Martin

  • lots of cairo changes and we now have better Cython + (py)cairo paint code which avoids the awful roundtrip via png: r7557 (and fixes in later changesets as well as build fixes for win32)
  • cursor support in 7573
  • opengl (only checks) ported in r7587
Last edited 3 years ago by Antoine Martin (previous) (diff)

comment:2 Changed 3 years ago by Antoine Martin

Description: modified (diff)
Owner: changed from Antoine Martin to Antoine Martin
Status: newassigned

Changed 3 years ago by Antoine Martin

Attachment: gtk3-gl-v4.patch added

work in progress patch for gtk3 + opengl support

Changed 3 years ago by Antoine Martin

Attachment: gtk3-gl-v8.patch added

dirty patch which sort of works if you ignore the stream of stacktraces!

Changed 3 years ago by Antoine Martin

Attachment: gtk3-gl-v10.patch added

working patch which breaks gtk2... so close!

Changed 3 years ago by Antoine Martin

Attachment: gtk3-gl-v11.patch added

working patch! just needs swap_buffers and packaging workaound for win32

Changed 3 years ago by Antoine Martin

Attachment: gtk3-gl-v13.patch added

cleaner version that works with single buffering only

comment:3 Changed 3 years ago by Antoine Martin

opengl support merged in r7599, but some big issues remain:

  • not tested on win32 since I don't have the hardware to test
  • python3 seems to have problems with pyopengl and memoryviews.. (so don't use video encodings for now - looks solvable)
  • the gtk3 code does not actually close the gl context and may leak resources (which is better than closing and crashing hard I guess)
  • the gtk3 uses contortions to try to call swap_buffers, creating a new window just to be able to call it.. (that's because the gi bindings don't give us the methods we need to get to the window... maybe we should assign the gl window to a custom widget when it gets realized instead?)

etc..

The code is still an improvement I think, and may help with #608.

If gtkgl proves too problematic with GTK3, maybe we can use a different approach, like this one: gtkgl via X11 + ctypes (at least for X11..)

Last edited 3 years ago by Antoine Martin (previous) (diff)

comment:4 Changed 3 years ago by Antoine Martin

Warning: r7573 introduced a crash on cursor stuff..
Until it is fixed, run with --no-cursors

comment:5 Changed 3 years ago by Antoine Martin

Much time wasted and still no clue: cursors are disabled on win32 until futher notice (done in r7625)

comment:6 Changed 3 years ago by Antoine Martin

More updates:

  • r7621 fixes the missing data on session info
  • r7622 ensures we honour the metadata
  • r7629 + r7630 remove some unnecessary bits, and the GTK3 installer is now pretty much the same size as the GTK2 one
  • r7607 added the GTK3 bits to the Fedora rpms
  • r7632 seems to fix CTRL_C

Summary of what's left:

  • opengl fixes: fix video support (array handle error) - see also #679
  • clipboard support
  • launcher fixes: missing widget..
  • fix webp support
  • session info graphs need rewriting using cairo
  • XSETTINGS and root property support
  • test for grabs and application-modal windows support

Delayed:

  • mouse cursors support (blocked by #678, which may fix things or at least help us figure out what the problem is)
  • packaging: use separate RPMs?
  • max-size switch (patch implemented, needs build system, see ticket:263#comment:12)
Last edited 3 years ago by Antoine Martin (previous) (diff)

Changed 3 years ago by Antoine Martin

Attachment: gtk3-win32-cursors.patch added

some work in progress to try to support cursors on win32 using cairo (requires gtk 3.10)

comment:7 Changed 3 years ago by Antoine Martin

RPM packaging for python3 in progress in r7673: we now generate 3 packages:

  • xpra-common with icons, /usr/bin scripts, etc
  • xpra (as before, the gtk2 client and server)
  • python3-xpra

New TODO items:

  • the shebang in the /usr/bin files should be neutral? (/usr/bin/env python?)
  • dependencies need checking and updating for python3-xpra:
    • requires_opengl
    • requires_sound
    • requires_lzo
    • python3-netifaces - requires spec file update
    • python-lz4 - requires spec file update
    • dbus-python is now python3-dbus (does it work?)
  • opengl apparently fails on win32: see ticket:90#comment:32 : some required OpenGL functions are not available: glActiveTexture, glMultiTexCoord2i - no idea why.
  • numpy 1.9.0 does not build..
Last edited 3 years ago by Antoine Martin (previous) (diff)

comment:9 Changed 3 years ago by Antoine Martin

r7599 broke opengl rendering on win32: it seems to revert to the GDI Generic renderer, and fails to locate some required opengl functions (GlActiveTexture and GlMultiTexCoord2i).

More worrying is that no-one noticed for 200+ revisions!

Last edited 3 years ago by Antoine Martin (previous) (diff)

comment:10 Changed 3 years ago by Antoine Martin

Correction: the bug was spotted 3 days ago, see ticket:684#comment:3 where I suggested a way to get to the fix (playing with the manual double buffering toggle).
As had been noted before (r2970, r2394), we MUST enable double buffering on win32: r7820 does this.

comment:11 Changed 3 years ago by Antoine Martin

A new pygobjectwin32 release is out based on GTK 3.14. Hopefully this one will work a bit better without requiring too many changes (packaging or other).

comment:12 Changed 3 years ago by Antoine Martin

Not too bad, r7931 allows us to build against this new release - sadly also breaks building against the older version...

Seems to work OK too. Downsides:

  • no theming (known upstream bug)
  • warnings about settings that are deprecated (icons, etc)

And still no development headers installed despite explicitly telling the installer we do want them, and even where we want them..

We still have to fix the cairo set_image_surface_data with no data bug too.

As per #734, maybe we can re-instate the cursor code?

See also #794 / #775.

Last edited 3 years ago by Antoine Martin (previous) (diff)

comment:13 Changed 3 years ago by Antoine Martin

Not worth breaking the GTK2 build! see r8651

comment:14 Changed 3 years ago by Antoine Martin

contrary to what is said in comment:6, r7632 did not fix the control-c handler, but r8736 does! (see #819)

comment:15 Changed 2 years ago by Antoine Martin

Some new sound problems, see ticket:669#comment:19

comment:16 Changed 2 years ago by Antoine Martin

I am now also seeing some paint problems, both with the opengl and cairo backends... sigh.

comment:17 Changed 2 years ago by Antoine Martin

I am seeing opengl rendering issues, so r9041 disables opengl by default on python3 (but it can still be enabled from the tray).

comment:18 Changed 2 years ago by Antoine Martin

The paint problems from comment:16 were probably resolved by the fixes in ticket:465#comment:19

comment:19 Changed 2 years ago by Antoine Martin

Also worth a try: updating to pygi-aio-3.14.0_rev16.

comment:20 Changed 2 years ago by Antoine Martin

Minor build fixes in r9064. Tweaking the distutils.cfg before building to match the compiler for each one of the BAT files is not longer required.

comment:21 Changed 2 years ago by Antoine Martin

With the numerous tedious changes in r9069, r9070 + r9071, r9072, we can finally build with mingw or with msvc out of the box after installing the latest pygi bindings (see comment:19). It is almost certain that older versions of the bindings will not build correctly - despite using the same release as base... (3.14.0)

r9073 fixes some broken mouse events with these latest builds (only on win32 + py3k)

For msvc builds you will need:

  • copy libwebp.lib to C:\Python34\libs to allow the webp codecs to link properly
  • copy mingw's libiconv-2.dll to C:\Python34\Lib\site-packages\gnome\ - somehow needed by the avcodec2 module (see r9074)? (why is the msvc build doing this?)

There is still a weird problem with the cairo workaround cython module:

  • with mingw, it builds, it loads and runs but causes crashes on exit (bad pointer, somewhere deep in pygilstate_reinit)
  • with msvc, it builds but does not load...

We do need this module to make things fast enough to be usable.

comment:22 Changed 2 years ago by Antoine Martin

It seems that the cairo workaround module actually does work, both with the msvc and mingw builds, just not on the build machine! (which makes it really tedious to test).
On the other hand, setting window icon works on the build machine and not on other test machines... also very tedious. r9077 disables setting window icons with GTK3 on win32. I'll need to figure it out later. (I'm sure I had seen this before, but can't find out what we're supposed to do - fixed size? buffer problem?)
Other new known problems:

  • the launcher doesn't start, doesn't complain either
  • sound doesn't seem to work, and causes crashes
  • exiting the client pops up an "unclean exit" dialog..

etc..
Is GTK3 really worth the pain?

PS: as of r9076, we include the type of build in the setup filename, ie:

  • Xpra-GTK3-py34-MSVC_Setup_0.15.0-r9076.exe
  • Xpra-GTK3-py34-MinGW_Setup_0.15.0-r9076.exe

We'll have to see which one is best.

comment:23 Changed 2 years ago by Antoine Martin

Stumbled upon these relevant comments (mostly on just how painful it is to move to python3): Python 3 adoption, in particular: qahirah: Qahirah is yet another Python language binding for the Cairo graphics library, for use with Python 3.2 or later. It is modelled to some extent on Pycairo.

Seeing how slow and poor the pycairo py3k bindings are (see r6394 for example), this could well be the solution we need. It has create_for_data wrapped, including the stride argument we need.

Last edited 2 years ago by Antoine Martin (previous) (diff)

comment:24 Changed 2 years ago by Antoine Martin

Important note (I had to rebuild everything as the update from Python 3.4.2 to 3.4.3 just failed mysteriously every time), for gmp follow these instructions: ticket:373#comment:6

Changed 2 years ago by Antoine Martin

Attachment: bencode-work9.patch added

work in progress patch - fixes bencode for py3k

comment:25 Changed 2 years ago by Antoine Martin

For the control-c handling, see ticket:626#comment:8

comment:26 Changed 2 years ago by Antoine Martin

comment:27 Changed 2 years ago by Antoine Martin

GTK3 won't play nice with KDE by the looks of things: https://bugzilla.gnome.org/show_bug.cgi?id=735211: I'm actually happy that it's stopped working.

Already broke our fix for XPRA/winswitch windows suffer from the default drag on all empty parts window dragging behaviour. (API got moved to gobject then removed completely).

Constant API churn when it's not missing altogether. Ouch.

Last edited 2 years ago by Antoine Martin (previous) (diff)

comment:28 Changed 2 years ago by Antoine Martin

From what I am reading, the "proper" way of building GTK3 stuff is to use MSYS2
See also:

Last edited 2 years ago by Antoine Martin (previous) (diff)

comment:29 Changed 2 years ago by Antoine Martin

New items (mostly related to #885):

  • AssertionError: grok_modifier_map needs porting to GTK3: maybe do it in pure X11, remove "nuisance"?
  • split common bits and GTK2 only bits: tray can be common, XError class can be common, world / wm / selection / gdk_bindings cannot be used with GTK3
  • HAS_X11_BINDINGS is too coarse
  • get_root_size for gtk3 is a workaround for win32, can we get rid of it now?

And maybe GTK3 handles max-size natively on win32? (so we could remove the window hooks we use as workaround - see #263)

Last edited 2 years ago by Antoine Martin (previous) (diff)

comment:30 Changed 2 years ago by Antoine Martin

This whole thread has useful pointers: Outdated win32 bundle

comment:31 Changed 2 years ago by Antoine Martin

Workaround for the gobject3 SIGINT problems added in r9747, for details see unable to trap SIGINT.
Once this bug is fixed, we should probably add a version check and disable the workarounds if the gobject version has the fix... meh.

comment:32 Changed 2 years ago by Antoine Martin

Milestone: 0.161.0

This is such a pain, going native might well be a quicker option. Re-scheduling.

comment:33 Changed 22 months ago by Antoine Martin

There are newer GTK3 builds available: pygobjectwin32

comment:34 Changed 21 months ago by Antoine Martin

Some work done on this for #1041, and some updates: where has gtkglext gone?

See this very good thread: http://markmail.org/message/umj6fzfimaptcxit: We have been asking for 15 years to include something like these 250 lines of code, that is ALL that is needed to bridge GtK and OpenGL.
So they've merged some similar code to https://github.com/tdz/gtkglext (the port to GTK3 of the original gtkglext): http://anzwix.com/a/GTK/GdkAddSupportForOpenGL (This commit contains only an implementation for X11 using GLX.) and later http://anzwix.com/a/GTK/WaylandAddOpenGLSupport) that does more or less what gtkglext has been doing for many many years... except this time, we no longer get win32 and osx support! What an improvement, not. Here's the ticket where this happened, which threw away all the good work done by tarnyko: https://bugzilla.gnome.org/show_bug.cgi?id=707723. (NIH syndrome?)

It gets worse https://www.bassi.io/articles/2015/02/17/using-opengl-with-gtk/: the OpenGL support inside GTK+ requires core GL profiles, and thus it won’t work with the fixed pipeline API that was common until OpenGL 3.2 and later versions. And the GDK drawing model was simpler, in those days, so these libraries just took a native windowing system surface, bound it to a GL context, and expected everything to work - well yes, I use an API and I expect it to work, crazy isn't it.

Let's see how hard it is to do for X11: How can i use gtk3 and opengl together? and GTK3 Displaying OpenGL inside a drawing area, trivial. Ouch.

Time to ditch GTK3? It's a train wreck. Things that used to work fine in GTK2, don't work at all: performance, opengl, win32 port, osx port?, API stability, etc..

Last edited 21 months ago by Antoine Martin (previous) (diff)

comment:35 Changed 21 months ago by Antoine Martin

Some notes on GTK3 (if we ever try to take this further): as done for #1041, we can probably remove more gir files and their dlls (see r11587)

comment:36 Changed 18 months ago by Antoine Martin

Found some build scripts for the full GTK3 stack: https://github.com/wingtk/gtk-win32 (based on the hexchat ones)

comment:37 Changed 18 months ago by Antoine Martin

GL still does not work in GTK3 on osx: https://bugzilla.gnome.org/show_bug.cgi?id=740199

comment:38 Changed 15 months ago by Antoine Martin

Milestone: 1.01.1

Milestone renamed

comment:39 Changed 13 months ago by Antoine Martin

Milestone: 1.12.0

Milestone renamed

comment:40 Changed 13 months ago by Antoine Martin

Blocked by #917 / #678 / #300, see also #1072

comment:41 Changed 8 months ago by Antoine Martin

Some python3 fixes in r14839.

It seems that the GTK3 gtkglext bindings have already been removed in Fedora 25.
To support opengl with GTK3 we would have to change the opengl code... and lose compatibility with the well supported and undoubtedly much more stable GTK2 backend. YUK.

Links:

Code examples:

Last edited 3 months ago by Antoine Martin (previous) (diff)

comment:42 Changed 7 months ago by Antoine Martin

Milestone: 2.03.0

Whatever the solution is, it is going to take a lot of work.

Re-scheduling.

comment:43 Changed 3 months ago by Antoine Martin

Minor improvements and fixes for 2.1:

  • r16223 fix dependency creep
  • r16224 + r16225 expose gdk pixbuf version
  • r16227 fix remote logging
  • r16228 fix jpeg decoder code (#1423)
  • r16229 fix painting!
  • r16230 + r16231 add paint box code to cairo and pixmap backends
  • r16232 click events (were doubled!)
  • r16234 + r16236 + r16237: session info fixes
  • r16239 pulseaudio pactl command output parsing fixes
  • r16240 + r16244 make X11 display setup explicit
  • r16241 + r16249 split out X11 generic code that isn't tied to GTK
  • r16242 access pulseaudio's X11 properties so we now also detect sound loops with python3
  • r16235 access version info from gtk / gdk / glib etc
  • r16247 merges the patch above - needed because we want the sound subprocess to use the gi bindings, and still be able to access X11 properties: it is easier to not use GDK
  • r16248 string vs bytes fixes in paint options dict
  • r16250 + r16251: handle transparency with cairo backend! works with both python2 and python3 (and supports box colors, etc)
  • r16253 + r16254: X11 context related fix and cleanup
Last edited 3 months ago by Antoine Martin (previous) (diff)

comment:44 Changed 3 months ago by Antoine Martin

As of r16251, the python3 client (and also python2 with cairo backend via XPRA_USE_CAIRO_BACKING=1) works as well as the pixmap backend.
The X11 bugs have been fixed, etc - see comment:43 for details.

Still TODO:

  • take a stab at opengl support - see comment:41
  • we should expose the backend information on session info?
  • add magic_key aka "border" painting support

comment:45 Changed 3 months ago by Antoine Martin

Resolution: fixed
Status: assignedclosed
Summary: Python3 GTK3 port feature parityPython3 GTK3 client feature parity

Minor fixes and improvements:

  • r16255: show window rendering backend information on session info features tab
  • r16256 + r16257: fix window border painting

Changed ticket scope: just the client is tracked here, so we can close this.
(there are too many fixes, so the backport is likely to just disable GTK3 in older branches)

Follow up python3 tickets:

Last edited 2 months ago by Antoine Martin (previous) (diff)

comment:46 Changed 2 months ago by Antoine Martin

Milestone: 3.02.1

(fix milestone)

Note: See TracTickets for help on using tickets.