Bug 1736049 - Stop calling `[[NSCursor currentCursor] set]` on every mouse move. r=emilio
authorMarkus Stange <mstange.moz@gmail.com>
Fri, 15 Oct 2021 16:52:33 +0000
changeset 596026 ff6d6594f7b046db57fa377eee3e8760a3ff4751
parent 596025 c5953b9d8df0eb1b130908bfcc6416742598312b
child 596027 deed5a3e46628648a3e1a77ddd23fbd52c52a5a3
push id38881
push userimoraru@mozilla.com
push dateFri, 15 Oct 2021 21:35:21 +0000
treeherdermozilla-central@ff6d6594f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1736049, 1735345, 496601, 1423275
milestone95.0a1
first release with
nightly linux32
ff6d6594f7b0 / 95.0a1 / 20211015213521 / files
nightly linux64
ff6d6594f7b0 / 95.0a1 / 20211015213521 / files
nightly mac
ff6d6594f7b0 / 95.0a1 / 20211015213521 / files
nightly win32
ff6d6594f7b0 / 95.0a1 / 20211015213521 / files
nightly win64
ff6d6594f7b0 / 95.0a1 / 20211015213521 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1736049 - Stop calling `[[NSCursor currentCursor] set]` on every mouse move. r=emilio This was only necessary when we had binary plug-ins overriding the cursor from under us. We no longer support plug-ins. Calling -[NSCursor set] has a performance cost on macOS Monterey when cursor accessibility coloring is enabled, so we want to avoid calling it unnecessarily. It also leaks memory in the current Monterey Beta (see bug 1735345), so calling it less often will leak less memory. I have checked the testcases of bug 496601 and of bug 1423275, they still work as expected with this fix. Differential Revision: https://phabricator.services.mozilla.com/D128612
widget/cocoa/nsCursorManager.mm
--- a/widget/cocoa/nsCursorManager.mm
+++ b/widget/cocoa/nsCursorManager.mm
@@ -206,21 +206,16 @@ static constexpr nsCursor kCustomCursor 
   return NS_OK;
 
   NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
 }
 
 - (nsresult)setMacCursor:(nsMacCursor*)aMacCursor {
   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
 
-  // Some plugins mess with our cursors and set a cursor that even
-  // [NSCursor currentCursor] doesn't know about. In case that happens, just
-  // reset the state.
-  [[NSCursor currentCursor] set];
-
   nsCursor oldType = [mCurrentMacCursor type];
   nsCursor newType = [aMacCursor type];
   if (oldType != newType) {
     if (newType == eCursor_none) {
       [NSCursor hide];
     } else if (oldType == eCursor_none) {
       [NSCursor unhide];
     }
@@ -240,17 +235,16 @@ static constexpr nsCursor kCustomCursor 
 }
 
 - (nsresult)setCustomCursor:(const nsIWidget::Cursor&)aCursor
           widgetScaleFactor:(CGFloat)scaleFactor {
   NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
 
   // As the user moves the mouse, this gets called repeatedly with the same aCursorImage
   if (sCurrentCursor == aCursor && sCurrentCursorScaleFactor == scaleFactor && mCurrentMacCursor) {
-    [self setMacCursor:mCurrentMacCursor];
     return NS_OK;
   }
 
   sCurrentCursor = aCursor;
   sCurrentCursorScaleFactor = scaleFactor;
 
   if (!aCursor.IsCustom()) {
     return NS_ERROR_FAILURE;