~ruther/guix-local

ref: 64668f7c15fa639831209f25e313c99a1047de7b guix-local/gnu/packages/patches/mpv-0.40.0-fix-wayland-cpu-usage.patch -rw-r--r-- 1.2 KiB
64668f7c — Rutherther etc: release: Add spare space to the release VM image. a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Upstream-status: https://github.com/mpv-player/mpv/pull/16140

From d20ded876d27497d3fe6a9494add8106b507a45c Mon Sep 17 00:00:00 2001
From: llyyr <llyyr.public@gmail.com>
Date: Fri, 28 Mar 2025 15:34:33 +0530
Subject: [PATCH] clipboard-wayland: prevent reading from hung up fd

This causes mpv to use up 100% of a core if there's an offer for a
mime_type that mpv doesn't accept with ext_data_control clipboard
backend.
---
 player/clipboard/clipboard-wayland.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/player/clipboard/clipboard-wayland.c b/player/clipboard/clipboard-wayland.c
index c4a5e50472..bd8ac35af2 100644
--- a/player/clipboard/clipboard-wayland.c
+++ b/player/clipboard/clipboard-wayland.c
@@ -348,6 +348,12 @@ static bool clipboard_wayland_dispatch_events(struct clipboard_wayland_priv *wl,
     if (fds[1].revents & POLLIN)
         return false;
 
+    if (fds[2].revents & (POLLERR | POLLHUP | POLLNVAL))
+        destroy_offer(wl->selection_offer);
+
+    if (fds[3].revents & (POLLERR | POLLHUP | POLLNVAL))
+        destroy_offer(wl->primary_selection_offer);
+
     if (fds[2].revents & POLLIN)
         get_selection_data(wl, wl->selection_offer, false);
 
-- 
2.51.0