[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 46/55] ui: Fix hanging up Cocoa display on macOS 10.15 (Catalina)
From: |
Michael Roth |
Subject: |
[PATCH 46/55] ui: Fix hanging up Cocoa display on macOS 10.15 (Catalina) |
Date: |
Tue, 5 Nov 2019 14:52:34 -0600 |
From: Hikaru Nishida <address@hidden>
macOS API documentation says that before applicationDidFinishLaunching
is called, any events will not be processed. However, some events are
fired before it is called in macOS Catalina. This causes deadlock of
iothread_lock in handleEvent while it will be released after the
app_started_sem is posted.
This patch avoids processing events before the app_started_sem is
posted to prevent this deadlock.
Buglink: https://bugs.launchpad.net/qemu/+bug/1847906
Signed-off-by: Hikaru Nishida <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
(cherry picked from commit dff742ad27efa474ec04accdbf422c9acfd3e30e)
Signed-off-by: Michael Roth <address@hidden>
---
ui/cocoa.m | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index c2984028c5..3026ead621 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -132,6 +132,7 @@ NSArray * supportedImageFileTypes;
static QemuSemaphore display_init_sem;
static QemuSemaphore app_started_sem;
+static bool allow_events;
// Utility functions to run specified code block with iothread lock held
typedef void (^CodeBlock)(void);
@@ -727,6 +728,16 @@ QemuCocoaView *cocoaView;
- (bool) handleEvent:(NSEvent *)event
{
+ if(!allow_events) {
+ /*
+ * Just let OSX have all events that arrive before
+ * applicationDidFinishLaunching.
+ * This avoids a deadlock on the iothread lock, which
cocoa_display_init()
+ * will not drop until after the app_started_sem is posted. (In theory
+ * there should not be any such events, but OSX Catalina now emits
some.)
+ */
+ return false;
+ }
return bool_with_iothread_lock(^{
return [self handleEventLocked:event];
});
@@ -1154,6 +1165,7 @@ QemuCocoaView *cocoaView;
- (void)applicationDidFinishLaunching: (NSNotification *) note
{
COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n");
+ allow_events = true;
/* Tell cocoa_display_init to proceed */
qemu_sem_post(&app_started_sem);
}
--
2.17.1
- [PATCH 39/55] block/snapshot: Restrict set of snapshot nodes, (continued)
- [PATCH 39/55] block/snapshot: Restrict set of snapshot nodes, Michael Roth, 2019/11/05
- [PATCH 03/55] s390x/tcg: Fix VERIM with 32/64 bit elements, Michael Roth, 2019/11/05
- [PATCH 43/55] qcow2: Limit total allocation range to INT_MAX, Michael Roth, 2019/11/05
- [PATCH 44/55] iotests: Test large write request to qcow2 file, Michael Roth, 2019/11/05
- [PATCH 47/55] virtio: new post_load hook, Michael Roth, 2019/11/05
- [PATCH 07/55] xen-bus: check whether the frontend is active during device reset..., Michael Roth, 2019/11/05
- [PATCH 48/55] virtio-net: prevent offloads reset on migration, Michael Roth, 2019/11/05
- [PATCH 42/55] hw/core/loader: Fix possible crash in rom_copy(), Michael Roth, 2019/11/05
- [PATCH 45/55] mirror: Do not dereference invalid pointers, Michael Roth, 2019/11/05
- [PATCH 52/55] target/arm: Allow reading flags from FPSCR for M-profile, Michael Roth, 2019/11/05
- [PATCH 46/55] ui: Fix hanging up Cocoa display on macOS 10.15 (Catalina),
Michael Roth <=
- [PATCH 50/55] util/hbitmap: strict hbitmap_reset, Michael Roth, 2019/11/05
- [PATCH 55/55] virtio-blk: Cancel the pending BH when the dataplane is reset, Michael Roth, 2019/11/05
- [PATCH 05/55] pc: Don't make die-id mandatory unless necessary, Michael Roth, 2019/11/05
- [PATCH 51/55] hbitmap: handle set/reset with zero length, Michael Roth, 2019/11/05
- [PATCH 08/55] block/file-posix: Reduce xfsctl() use, Michael Roth, 2019/11/05
- [PATCH 04/55] target/alpha: fix tlb_fill trap_arg2 value for instruction fetch, Michael Roth, 2019/11/05
- [PATCH 06/55] xen-bus: Fix backend state transition on device reset, Michael Roth, 2019/11/05
- [PATCH 21/55] qcow2: Fix the calculation of the maximum L2 cache size, Michael Roth, 2019/11/05
- [PATCH 53/55] target/xtensa: regenerate and re-import test_mmuhifi_c3 core, Michael Roth, 2019/11/05
- [PATCH 25/55] curl: Check completion in curl_multi_do(), Michael Roth, 2019/11/05