From 26c6b2579543e928158fa7d3c00d8b0e04ac270c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 5 Apr 2019 15:04:10 -0400 Subject: devdraw: avoid deadlock on pre-Mojave macOS --- src/cmd/devdraw/cocoa-screen.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index c2489a6c..97128da2 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -541,6 +541,11 @@ _flushmemscreen(Rectangle r) return; rect = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); + + // This can get blocked behind responding to mouse events, + // which need to acquire the zlock, so let go of it during + // the flush. Perhaps the waitUntilDone:YES is wrong? + zunlock(); [appdelegate performSelectorOnMainThread:@selector(callflushimg:) withObject:[NSValue valueWithRect:rect] @@ -548,6 +553,7 @@ _flushmemscreen(Rectangle r) modes:[NSArray arrayWithObjects: NSRunLoopCommonModes, @"waiting image", nil]]; + zlock(); } static void drawimg(NSRect, uint); -- cgit v1.2.3