Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-21944

QCocoaView recreates/readds tracking areas for no reason, which causes significant GUI performance issues

    XMLWordPrintable

Details

    • 5e8e04a29ff15e8b329c758f2ea62b8e6feb70f9

    Description

      In Qt/Cocoa tracking area's are constantly removed and recreated/readded, which is terribly slow and unnecessary when NSTrackingInVisibleRect is used as option (it will ignore the NSTrackingArea rect in favour of the NSView visibleRect). Here's a proper implementation of updateTrackingAreas:

      - (void)updateTrackingAreas
      {
          if (!qwidget)
              return;
      
          // [NSView addTrackingArea] is slow, so bail out early if we can:
          if (NSIsEmptyRect([self visibleRect]))
              return;
      
          QMacCocoaAutoReleasePool pool;
      
          if ([[self trackingAreas] count] > 0)
              return;
      	
          // Ideally, we shouldn't have NSTrackingMouseMoved events included below, it should
          // only be turned on if mouseTracking, hover is on or a tool tip is set.
          // Unfortunately, Qt will send "tooltip" events on mouse moves, so we need to
          // turn it on in ALL case. That means EVERY QCocoaView gets to pay the cost of
          // mouse moves delivered to it (Apple recommends keeping it OFF because there
          // is a performance hit). So it goes.
          NSUInteger trackingOptions = NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp
                                       | NSTrackingInVisibleRect | NSTrackingMouseMoved;
          NSTrackingArea *ta = [[NSTrackingArea alloc] initWithRect:NSMakeRect(0, 0, 1, 1)
                                                             options:trackingOptions
                                                              owner:self
                                                           userInfo:nil];
          [self addTrackingArea:ta];
          [ta release];
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            con Eike Ziller
            antipro Karel Bassez
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes