Copy using the right destination stride

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1882718
This commit is contained in:
Jonas Ådahl 2020-10-12 18:52:44 +02:00
parent ef24ef5b54
commit c026821a7a
2 changed files with 78 additions and 1 deletions

View File

@ -0,0 +1,71 @@
From 81172effba7c70d3b2932c67be79a2924eae9d73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
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

View File

@ -2,7 +2,7 @@
Name: gnome-remote-desktop Name: gnome-remote-desktop
Version: 0.1.9 Version: 0.1.9
Release: 1%{?dist} Release: 2%{?dist}
Summary: GNOME Remote Desktop screen share service Summary: GNOME Remote Desktop screen share service
License: GPLv2+ License: GPLv2+
@ -15,6 +15,9 @@ Patch0: 0001-vnc-Drop-frames-if-client-is-gone.patch
# Adds encryption support (requires patched LibVNCServer) # Adds encryption support (requires patched LibVNCServer)
Patch1: gnutls-anontls.patch Patch1: gnutls-anontls.patch
# Copy using the right destination stride
Patch2: 0001-vnc-Copy-pixels-using-the-right-destination-stride.patch
BuildRequires: git BuildRequires: git
BuildRequires: gcc BuildRequires: gcc
BuildRequires: meson >= 0.36.0 BuildRequires: meson >= 0.36.0
@ -74,6 +77,9 @@ GNOME desktop environment.
%changelog %changelog
* Mon Sep 14 2020 Jonas Ådahl <jadahl@redhat.com> - 0.1.9-2
- Copy using the right destination stride
* Mon Sep 14 2020 Jonas Ådahl <jadahl@redhat.com> - 0.1.9-1 * Mon Sep 14 2020 Jonas Ådahl <jadahl@redhat.com> - 0.1.9-1
- Update to 0.1.9 - Update to 0.1.9
- Backport race condition crash fix - Backport race condition crash fix