Subject: bug#74369: bug#72496: 31.0.50; macOS: freezes without beach ball

From: Gerd Möllmann <[email-masked]>
Date: Wed, 28 May 2025 06:41:10 +0200

Gerd Möllmann <[email-masked]> writes:

FWIW, and for posterity, I am now using the patch below. This makes the
freezes without beach ball that I described literally impossible. 

1 file changed, 17 insertions(+), 1 deletion(-)
src/nsterm.m | 18 +++++++++++++++++-

modified   src/nsterm.m
@@ -6132,7 +6132,23 @@ - (void)sendEvent: (NSEvent *)theEvent
 
   NSTRACE_UNSILENCE();
 
-  [super sendEvent: theEvent];
+  [super sendEvent:theEvent];
+
+#ifdef NS_IMPL_COCOA
+  /* We have the problem that app-defined events get lost for an unknown
+     reason. When that happens, Emacs still processes NS events, and no
+     beach ball is displayed. But Emacs' own event loop does not gain
+     control again and it doesn't react to input anymore.  */
+  if ([NSApp modalWindow] != nil)
+    return;
+
+  static int count = 0;
+  if (++count == 10)
+    {
+      count = 0;
+      [self stop: self];
+    }
+#endif
 }