diff --git a/0001-vnc-Copy-pixels-using-the-right-destination-stride.patch b/0001-vnc-Copy-pixels-using-the-right-destination-stride.patch new file mode 100644 index 0000000..fc5c830 --- /dev/null +++ b/0001-vnc-Copy-pixels-using-the-right-destination-stride.patch @@ -0,0 +1,71 @@ +From 81172effba7c70d3b2932c67be79a2924eae9d73 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Mon, 12 Oct 2020 17:34:30 +0200 +Subject: [PATCH] vnc: Copy pixels using the right destination stride + +We're copying the pixels in a separate thread managed by PipeWire, and +in this thread, accessing the VNC framebuffer dimension and stride is +racy. Instead of fetching the dimension directly, pass the expected +width and get the stride it will eventually have. + +Already before this patch, when the copied pixel end up on the main +thread and the dimension still doesn't match up, the frame will be +dropped. +--- + src/grd-session-vnc.c | 5 +++-- + src/grd-session-vnc.h | 3 ++- + src/grd-vnc-pipewire-stream.c | 5 +++-- + 3 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/src/grd-session-vnc.c b/src/grd-session-vnc.c +index 69fb33d..f4835aa 100644 +--- a/src/grd-session-vnc.c ++++ b/src/grd-session-vnc.c +@@ -535,9 +535,10 @@ grd_session_vnc_get_fd (GrdSessionVnc *session_vnc) + } + + int +-grd_session_vnc_get_framebuffer_stride (GrdSessionVnc *session_vnc) ++grd_session_vnc_get_stride_for_width (GrdSessionVnc *session_vnc, ++ int width) + { +- return session_vnc->rfb_screen->paddedWidthInBytes; ++ return width * BGRX_BYTES_PER_PIXEL; + } + + rfbClientPtr +diff --git a/src/grd-session-vnc.h b/src/grd-session-vnc.h +index 0d01ad3..ccd046c 100644 +--- a/src/grd-session-vnc.h ++++ b/src/grd-session-vnc.h +@@ -60,7 +60,8 @@ void grd_session_vnc_move_cursor (GrdSessionVnc *session_vnc, + + int grd_session_vnc_get_fd (GrdSessionVnc *session_vnc); + +-int grd_session_vnc_get_framebuffer_stride (GrdSessionVnc *session_vnc); ++int grd_session_vnc_get_stride_for_width (GrdSessionVnc *session_vnc, ++ int width); + + gboolean grd_session_vnc_is_client_gone (GrdSessionVnc *session_vnc); + +diff --git a/src/grd-vnc-pipewire-stream.c b/src/grd-vnc-pipewire-stream.c +index 96dd7c9..82ceb9b 100644 +--- a/src/grd-vnc-pipewire-stream.c ++++ b/src/grd-vnc-pipewire-stream.c +@@ -326,10 +326,11 @@ process_buffer (GrdVncPipeWireStream *stream, + int height; + int y; + +- src_stride = buffer->datas[0].chunk->stride; +- dst_stride = grd_session_vnc_get_framebuffer_stride (stream->session); + height = stream->spa_format.size.height; + width = stream->spa_format.size.width; ++ src_stride = buffer->datas[0].chunk->stride; ++ dst_stride = grd_session_vnc_get_stride_for_width (stream->session, ++ width); + + frame->data = g_malloc (height * dst_stride); + for (y = 0; y < height; y++) +-- +2.28.0 + diff --git a/gnome-remote-desktop.spec b/gnome-remote-desktop.spec index ecad0c8..6f2760b 100644 --- a/gnome-remote-desktop.spec +++ b/gnome-remote-desktop.spec @@ -2,7 +2,7 @@ Name: gnome-remote-desktop Version: 0.1.9 -Release: 1%{?dist} +Release: 2%{?dist} Summary: GNOME Remote Desktop screen share service License: GPLv2+ @@ -15,6 +15,9 @@ Patch0: 0001-vnc-Drop-frames-if-client-is-gone.patch # Adds encryption support (requires patched LibVNCServer) Patch1: gnutls-anontls.patch +# Copy using the right destination stride +Patch2: 0001-vnc-Copy-pixels-using-the-right-destination-stride.patch + BuildRequires: git BuildRequires: gcc BuildRequires: meson >= 0.36.0 @@ -74,6 +77,9 @@ GNOME desktop environment. %changelog +* Mon Sep 14 2020 Jonas Ådahl - 0.1.9-2 +- Copy using the right destination stride + * Mon Sep 14 2020 Jonas Ådahl - 0.1.9-1 - Update to 0.1.9 - Backport race condition crash fix