Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window-list: Render thumbnails as cairo surfaces #1168

Merged
merged 1 commit into from Dec 8, 2020

Conversation

vkareh
Copy link
Member

@vkareh vkareh commented Dec 4, 2020

This allows thumbnail previews to be properly rendered on HiDPI displays
and ensures that the window surface is flushed before painting it.

Fixes #1166

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builds and runs fine,didn't put any runtime errors in ~/.xsession-errors
Tested with a 4K monitor and oh yeah this makes much sharper window previews, this basic change is tried and true for dealing with hidpi. I don't have the problematic cairo 1.17 to test against (we have 1.16 in Debian Unstable right now) so I cannot evaluate whether it fixes that crash, but this sure as hell makes nicer previews with 4K

@lukefromdc lukefromdc requested a review from a team December 4, 2020 22:50
@lukefromdc
Copy link
Member

I built a .deb of this rebased against today's master, so it's my day to day panel for now, working well

@rbuj rbuj self-requested a review December 5, 2020 22:38
Copy link
Contributor

@rbuj rbuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A segment violation is still occurring. Test:

$ git clone https://github.com/freedesktop/cairo.git
$ cd cairo
$ git log -1 --pretty=%h
f7054c892
$ ./autogen.sh --prefix=/usr --enable-xlib-xcb && make &> /dev/null && sudo make install &> /dev/null
<cut>
cairo (version 1.17.3 [git]) will be compiled with:

The following surface backends:
  Image:         yes (always builtin)
  Recording:     yes (always builtin)
  Observer:      yes (always builtin)
  Mime:          yes (always builtin)
  Tee:           no (disabled, use --enable-tee to enable)
  XML:           no (disabled, use --enable-xml to enable)
  Xlib:          yes
  Xlib Xrender:  yes
  Qt:            no (disabled, use --enable-qt to enable)
  Quartz:        no (requires CoreGraphics framework)
  Quartz-image:  no (disabled, use --enable-quartz-image to enable)
  XCB:           yes
  Win32:         no (requires a Win32 platform)
  OS2:           no (disabled, use --enable-os2 to enable)
  CairoScript:   yes
  PostScript:    yes
  PDF:           yes
  SVG:           yes
  OpenGL:        no (disabled, use --enable-gl to enable)
  OpenGL ES 2.0: no (disabled, use --enable-glesv2 to enable)
  OpenGL ES 3.0: no (disabled, use --enable-glesv3 to enable)
  BeOS:          no (disabled, use --enable-beos to enable)
  DirectFB:      no (disabled, use --enable-directfb to enable)
  OpenVG:        no (disabled, use --enable-vg to enable)
  DRM:           no (disabled, use --enable-drm to enable)
  Cogl:          no (disabled, use --enable-cogl to enable)

The following font backends:
  User:          yes (always builtin)
  FreeType:      yes
  Fontconfig:    yes
  Win32:         no (requires a Win32 platform)
  Quartz:        no (requires CoreGraphics framework)

The following functions:
  PNG functions:   yes
  GLX functions:   no (not required by any backend)
  WGL functions:   no (not required by any backend)
  EGL functions:   no (not required by any backend)
  X11-xcb functions: yes
  XCB-shm functions: yes

The following features and utilities:
  cairo-trace:                yes
  cairo-script-interpreter:   yes

And the following internal features:
  pthread:       yes
  gtk-doc:       no
  gcov support:  no
  symbol-lookup: no (requires bfd)
  test surfaces: no (disabled, use --enable-test-surfaces to enable)
  ps testing:    yes
  pdf testing:   yes
  svg testing:   yes


--- The Xlib/XCB functions feature is still under active development and is
--- included in this release only as a preview. It does NOT fully work yet
--- and incompatible changes may yet be made to Xlib/XCB functions specific
--- API.
$ git clone https://github.com/mate-desktop/mate-panel.git
$ cd mate-panel
$ git checkout cairo-thumbnail-previews
$ ./autogen.sh --prefix=/usr && make &> /dev/null && sudo make install &> /dev/null
<cut>

              mate-panel 1.25.1
              =================

        prefix:                        /usr
        exec_prefix:                   ${prefix}
        libdir:                        ${exec_prefix}/lib64
        bindir:                        ${exec_prefix}/bin
        sbindir:                       ${exec_prefix}/sbin
        sysconfdir:                    /etc
        localstatedir:                 /var
        datadir:                       ${datarootdir}
        source code location:          .
        compiler:                      gcc
        cflags:                        
        warning flags:                 -Wall -Wmissing-prototypes
        Maintainer mode:               yes
        Use *_DISABLE_DEPRECATED:      no
        Applets to build in-process:   (none)
        Wayland support:               yes
        X11 support:                   yes
        XRandr support:                yes
        Build introspection support:   yes
        Build gtk-doc documentation:   no


Now type `make' to compile mate-panel

Dec 05 23:39:37 localhost.localdomain systemd-coredump[147815]: [LNK] Process 147360 (wnck-applet) of user 1000 dumped core.
                                                                
                                                                Stack trace of thread 147360:
                                                                #0  0x00007fdde78629d5 raise (libc.so.6 + 0x3d9d5)
                                                                #1  0x00007fdde784b8a4 abort (libc.so.6 + 0x268a4)
                                                                #2  0x00007fdde784b789 __assert_fail_base.cold (libc.so.6 + 0x26789)
                                                                #3  0x00007fdde785b026 __assert_fail (libc.so.6 + 0x36026)
                                                                #4  0x00007fdde835ccb1 INT_cairo_surface_mark_dirty_rectangle (libcairo.so.2 + 0x6fcb1)
                                                                #5  0x00007fdde837e830 _cairo_xlib_xcb_surface_mark_dirty (libcairo.so.2 + 0x91830)
                                                                #6  0x00007fdde835cc09 INT_cairo_surface_mark_dirty_rectangle (libcairo.so.2 + 0x6fc09)
                                                                #7  0x00007fdde835e1c5 INT_cairo_surface_mark_dirty (libcairo.so.2 + 0x711c5)
                                                                #8  0x0000000000408943 preview_window_thumbnail (wnck-applet + 0x8943)
                                                                #9  0x0000000000408dac applet_enter_notify_event (wnck-applet + 0x8dac)
                                                                #10 0x00007fdde7b7a4a1 g_cclosure_marshal_VOID__POINTERv (libgobject-2.0.so.0 + 0x124a1)
                                                                #11 0x00007fdde7b99080 g_signal_emit_valist (libgobject-2.0.so.0 + 0x31080)
                                                                #12 0x00007fdde7b991a3 g_signal_emit (libgobject-2.0.so.0 + 0x311a3)
                                                                #13 0x00007fdde8ea18d0 wnck_task_enter_notify_event (libwnck-3.so.0 + 0x1e8d0)
                                                                #14 0x00007fdde8a3c59b _gtk_marshal_BOOLEAN__BOXED (libgtk-3.so.0 + 0x3de59b)
                                                                #15 0x00007fdde7b7be2a g_closure_invoke (libgobject-2.0.so.0 + 0x13e2a)
                                                                #16 0x00007fdde7ba5273 signal_emit_unlocked_R.isra.0 (libgobject-2.0.so.0 + 0x3d273)
                                                                #17 0x00007fdde7b98aee g_signal_emit_valist (libgobject-2.0.so.0 + 0x30aee)
                                                                #18 0x00007fdde7b991a3 g_signal_emit (libgobject-2.0.so.0 + 0x311a3)
                                                                #19 0x00007fdde8a03184 gtk_widget_event_internal.part.0.lto_priv.0 (libgtk-3.so.0 + 0x3a5184)
                                                                #20 0x00007fdde88a67b7 gtk_main_do_event (libgtk-3.so.0 + 0x2487b7)
                                                                #21 0x00007fdde8595043 _gdk_event_emit (libgdk-3.so.0 + 0x35043)
                                                                #22 0x00007fdde85cbfc2 gdk_event_source_dispatch (libgdk-3.so.0 + 0x6bfc2)
                                                                #23 0x00007fdde7a8a7ef g_main_context_dispatch (libglib-2.0.so.0 + 0x537ef)
                                                                #24 0x00007fdde7adc5d8 g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xa55d8)
                                                                #25 0x00007fdde7a89eb3 g_main_loop_run (libglib-2.0.so.0 + 0x52eb3)
                                                                #26 0x00007fdde88a220d gtk_main (libgtk-3.so.0 + 0x24420d)
                                                                #27 0x00007fdde8ed4a54 _mate_panel_applet_factory_main_internal (libmate-panel-applet-4.so.1 + 0xca54)
                                                                #28 0x00007fdde8ed4aa9 mate_panel_applet_factory_main (libmate-panel-applet-4.so.1 + 0xcaa9)
                                                                #29 0x00000000004079de main (wnck-applet + 0x79de)
                                                                #30 0x00007fdde784d1e2 __libc_start_main (libc.so.6 + 0x281e2)
                                                                #31 0x000000000040725e _start (wnck-applet + 0x725e)
                                                                
                                                                Stack trace of thread 147366:
                                                                #0  0x00007fdde791b80f __poll (libc.so.6 + 0xf680f)
                                                                #1  0x00007fdde7adc576 g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xa5576)
                                                                #2  0x00007fdde7a87bc3 g_main_context_iteration (libglib-2.0.so.0 + 0x50bc3)
                                                                #3  0x00007fdde7a897e1 glib_worker_main (libglib-2.0.so.0 + 0x527e1)
                                                                #4  0x00007fdde7ab8132 g_thread_proxy (libglib-2.0.so.0 + 0x81132)
                                                                #5  0x00007fdde82d43f9 start_thread (libpthread.so.0 + 0x93f9)
                                                                #6  0x00007fdde7926903 __clone (libc.so.6 + 0x101903)
                                                                
                                                                Stack trace of thread 147367:
                                                                #0  0x00007fdde792130d syscall (libc.so.6 + 0xfc30d)
                                                                #1  0x00007fdde7ad716c g_cond_wait_until (libglib-2.0.so.0 + 0xa016c)
                                                                #2  0x00007fdde7a5b381 g_async_queue_pop_intern_unlocked (libglib-2.0.so.0 + 0x24381)
                                                                #3  0x00007fdde7a5b506 g_async_queue_timeout_pop (libglib-2.0.so.0 + 0x24506)
                                                                #4  0x00007fdde7abad79 g_thread_pool_thread_proxy.lto_priv.0 (libglib-2.0.so.0 + 0x83d79)
                                                                #5  0x00007fdde7ab8132 g_thread_proxy (libglib-2.0.so.0 + 0x81132)
                                                                #6  0x00007fdde82d43f9 start_thread (libpthread.so.0 + 0x93f9)
                                                                #7  0x00007fdde7926903 __clone (libc.so.6 + 0x101903)
                                                                
                                                                Stack trace of thread 147368:
                                                                #0  0x00007fdde791b80f __poll (libc.so.6 + 0xf680f)
                                                                #1  0x00007fdde7adc576 g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xa5576)
                                                                #2  0x00007fdde7a89eb3 g_main_loop_run (libglib-2.0.so.0 + 0x52eb3)
                                                                #3  0x00007fdde7cd1d1a gdbus_shared_thread_func.lto_priv.0 (libgio-2.0.so.0 + 0x10fd1a)
                                                                #4  0x00007fdde7ab8132 g_thread_proxy (libglib-2.0.so.0 + 0x81132)
                                                                #5  0x00007fdde82d43f9 start_thread (libpthread.so.0 + 0x93f9)
                                                                #6  0x00007fdde7926903 __clone (libc.so.6 + 0x101903)
                                                                
                                                                Stack trace of thread 147501:
                                                                #0  0x00007fdde791b80f __poll (libc.so.6 + 0xf680f)
                                                                #1  0x00007fdde7adc576 g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xa5576)
                                                                #2  0x00007fdde7a87bc3 g_main_context_iteration (libglib-2.0.so.0 + 0x50bc3)
                                                                #3  0x00007fdde8ee664d dconf_gdbus_worker_thread (libdconfsettings.so + 0x664d)
                                                                #4  0x00007fdde7ab8132 g_thread_proxy (libglib-2.0.so.0 + 0x81132)
                                                                #5  0x00007fdde82d43f9 start_thread (libpthread.so.0 + 0x93f9)
                                                                #6  0x00007fdde7926903 __clone (libc.so.6 + 0x101903)

Edit: gdb bt

(gdb) 
#0  0x00007fe6b6e939d5 in raise () at /lib64/libc.so.6
#1  0x00007fe6b6e7c8a4 in abort () at /lib64/libc.so.6
#2  0x00007fe6b6e7c789 in _nl_load_domain.cold () at /lib64/libc.so.6
#3  0x00007fe6b6e8c026 in annobin_assert.c_end () at /lib64/libc.so.6
#4  0x00007fe6b79b6f89 in INT_cairo_surface_mark_dirty_rectangle (surface=0x125db70, x=0, y=0, width=1812, height=1125) at cairo-surface.c:1733
#5  0x00007fe6b79e6e23 in _cairo_xlib_xcb_surface_mark_dirty (abstract_surface=0x1222150, x=0, y=0, width=1812, height=1125) at cairo-xlib-xcb-surface.c:265
#6  0x00007fe6b79b7093 in INT_cairo_surface_mark_dirty_rectangle (surface=0x1222150, x=0, y=0, width=1812, height=1125) at cairo-surface.c:1756
#7  0x00007fe6b79b6ed0 in INT_cairo_surface_mark_dirty (surface=0x1222150) at cairo-surface.c:1687
#8  0x0000000000408943 in preview_window_thumbnail (wnck_window=0x11987c0, tasklist=0x10e2400) at window-list.c:275
#9  0x0000000000408dac in applet_enter_notify_event (tl=0x118c320, wnck_windows=0xffe080 = {...}, tasklist=0x10e2400) at window-list.c:400
#10 0x00007fe6b71ab4a1 in g_cclosure_marshal_VOID__POINTERv () at /lib64/libgobject-2.0.so.0
#11 0x00007fe6b71ca080 in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
#12 0x00007fe6b71ca1a3 in g_signal_emit () at /lib64/libgobject-2.0.so.0
#13 0x00007fe6b85258d0 in wnck_task_enter_notify_event () at /lib64/libwnck-3.so.0
#14 0x00007fe6b80c059b in _gtk_marshal_BOOLEAN__BOXED () at /lib64/libgtk-3.so.0
#15 0x00007fe6b71ace2a in g_closure_invoke () at /lib64/libgobject-2.0.so.0
#16 0x00007fe6b71d6273 in signal_emit_unlocked_R.isra.0 () at /lib64/libgobject-2.0.so.0
#17 0x00007fe6b71c9aee in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
#18 0x00007fe6b71ca1a3 in g_signal_emit () at /lib64/libgobject-2.0.so.0
#19 0x00007fe6b8087184 in gtk_widget_event_internal.part.0.lto_priv () at /lib64/libgtk-3.so.0
#20 0x00007fe6b7f2a7b7 in gtk_main_do_event () at /lib64/libgtk-3.so.0
#21 0x00007fe6b7c19043 in _gdk_event_emit () at /lib64/libgdk-3.so.0
#22 0x00007fe6b7c4ffc2 in gdk_event_source_dispatch () at /lib64/libgdk-3.so.0
#23 0x00007fe6b70bb7ef in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
#24 0x00007fe6b710d5d8 in g_main_context_iterate.constprop () at /lib64/libglib-2.0.so.0
#25 0x00007fe6b70baeb3 in g_main_loop_run () at /lib64/libglib-2.0.so.0
#26 0x00007fe6b7f2620d in gtk_main () at /lib64/libgtk-3.so.0
#27 0x00007fe6b8558a54 in _mate_panel_applet_factory_main_internal (factory_id=0x410171 "WnckletFactory", out_process=1, applet_type=, callback=0x40776c <wncklet_factory>, user_data=0x0) at mate-panel-applet.c:2344
#28 0x00007fe6b8558aa9 in mate_panel_applet_factory_main (factory_id=0x410171 "WnckletFactory", out_process=1, applet_type=, callback=0x40776c <wncklet_factory>, user_data=0x0) at mate-panel-applet.c:2372
#29 0x00000000004079de in main (argc=1, argv=0x7ffc06acfda8) at wncklet.c:155

@lukefromdc
Copy link
Member

I don't have cairo 1.17 here, so can't work on that part of the problem

@lukefromdc
Copy link
Member

OK, we now have a report
#1166 (comment)
that a new cairo version (1.17.4-2) fixes the crash with cairo 1.17 in Arch. We also know this PR gives much better thumbnail rendering in Hidpi. This should also be tested with cairo 1.17.4-2 but if it passes that should be ready to go unless someone else finds a new problem

applets/wncklet/window-list.c Outdated Show resolved Hide resolved
applets/wncklet/window-list.c Outdated Show resolved Hide resolved
This allows thumbnail previews to be properly rendered on HiDPI displays
and ensures that the window surface is flushed before painting it.
Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I got good results with the latest version of this PR with a 4K monitor and cairo 1.16

Copy link
Contributor

@rbuj rbuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test: save thumbnail in home folder (HiDPI 2: gsettings set org.mate.interface window-scaling-factor 2)

$ file thumbnail-*.png
thumbnail-master.png: PNG image data, 200 x 132, 8-bit/color RGBA, non-interlaced
thumbnail-pr.png:     PNG image data, 400 x 264, 8-bit/color RGB, non-interlaced

master

diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c
index 6038400e..e211047e 100644
--- a/applets/wncklet/window-list.c
+++ b/applets/wncklet/window-list.c
@@ -338,6 +338,11 @@ static gboolean preview_window_draw (GtkWidget *widget, cairo_t *cr, GdkPixbuf *
 
        context = gtk_widget_get_style_context (widget);
        gtk_render_icon (context, cr, thumbnail, 0, 0);
+#if 1
+       gchar *filename = g_build_filename (g_get_home_dir (), "thumbnail.png", NULL);
+       gdk_pixbuf_save (thumbnail, filename, "png", NULL, NULL);
+       g_free (filename);
+#endif
 
        return FALSE;
 }

pr

diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c
index 4708d56c..be632dce 100644
--- a/applets/wncklet/window-list.c
+++ b/applets/wncklet/window-list.c
@@ -359,6 +359,11 @@ static gboolean preview_window_draw (GtkWidget *widget, cairo_t *cr, cairo_surfa
 
        context = gtk_widget_get_style_context (widget);
        gtk_render_icon_surface (context, cr, thumbnail, 0, 0);
+#if 1
+       gchar *filename = g_build_filename (g_get_home_dir (), "thumbnail.png", NULL);
+       cairo_surface_write_to_png (thumbnail, filename);
+       g_free (filename);
+#endif
 
        return FALSE;
 }

master

thumbnail-master

pr

thumbnail-pr

@rbuj rbuj merged commit 0b455a7 into master Dec 8, 2020
@rbuj rbuj deleted the cairo-thumbnail-previews branch December 8, 2020 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window List Quit Unexpectedly when hovering
3 participants