Bug 705154 - Hang monitor incorrectly killing the app on mac when the user is idle: unlike other platforms, the main loop on Mac doesn't call processNextEvent in a loop: instead it calls into [NSApplication run] and we check whether there are pending XPCOM events during processing. Suspend the hang monitor when we pause for incoming events by subclassing [NSApplication nextEventMatchingMask], r=smichaud
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 01 Dec 2011 12:50:04 -0500
changeset 81089 1b3f17ffa656540baebc5cac1e5df43e0303d587
parent 81088 eec3aca1b188be477b59b1d922d49dbcf518b5b8
child 81090 c120734d20ba448629dd4fc97e8441c33bcd1e01
child 81100 b4827b51003b1646ad5dbda7bc5f6b649c786021
push id21554
push usermbrubeck@mozilla.com
push dateThu, 01 Dec 2011 19:19:16 +0000
treeherdermozilla-central@c120734d20ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs705154
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 705154 - Hang monitor incorrectly killing the app on mac when the user is idle: unlike other platforms, the main loop on Mac doesn't call processNextEvent in a loop: instead it calls into [NSApplication run] and we check whether there are pending XPCOM events during processing. Suspend the hang monitor when we pause for incoming events by subclassing [NSApplication nextEventMatchingMask], r=smichaud
widget/src/cocoa/nsAppShell.mm
--- a/widget/src/cocoa/nsAppShell.mm
+++ b/widget/src/cocoa/nsAppShell.mm
@@ -178,26 +178,40 @@ bool nsCocoaAppModalWindowList::GeckoMod
 //
 // Subclass of NSApplication for filtering out certain events.
 @interface GeckoNSApplication : NSApplication
 {
 }
 @end
 
 @implementation GeckoNSApplication
+
 - (void)sendEvent:(NSEvent *)anEvent
 {
   mozilla::HangMonitor::NotifyActivity();
   if ([anEvent type] == NSApplicationDefined &&
       [anEvent subtype] == kEventSubtypeTrace) {
     mozilla::SignalTracerThread();
     return;
   }
   [super sendEvent:anEvent];
 }
+
+- (NSEvent*)nextEventMatchingMask:(NSUInteger)mask
+                        untilDate:(NSDate*)expiration
+                           inMode:(NSString*)mode
+                          dequeue:(BOOL)flag
+{
+  if (expiration) {
+    mozilla::HangMonitor::Suspend();
+  }
+  return [super nextEventMatchingMask:mask
+          untilDate:expiration inMode:mode dequeue:flag];
+}
+
 @end
 
 
 // AppShellDelegate
 //
 // Cocoa bridge class.  An object of this class is registered to receive
 // notifications.
 //