Changeset 211362 in webkit


Ignore:
Timestamp:
Jan 30, 2017 4:07:15 AM (7 years ago)
Author:
akling@apple.com
Message:

[macOS] WebHTMLView has an internal retain cycle with its flagsChangedEventMonitor.
<https://webkit.org/b/167580>

Reviewed by Antti Koivisto.

Avoid the implicit strong capture of self by keeping it in a block variable.
Also add code to dealloc to unregister the event monitor, since it will otherwise leak.
This fixes huge WebHTMLView leaks seen on the leaks bot.

  • WebView/WebHTMLView.mm:

(-[WebHTMLViewPrivate dealloc]):
(-[WebHTMLView viewDidMoveToWindow]):

Location:
trunk/Source/WebKit/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r211355 r211362  
     12017-01-30  Andreas Kling  <akling@apple.com>
     2
     3        [macOS] WebHTMLView has an internal retain cycle with its flagsChangedEventMonitor.
     4        <https://webkit.org/b/167580>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Avoid the implicit strong capture of self by keeping it in a __block variable.
     9        Also add code to dealloc to unregister the event monitor, since it will otherwise leak.
     10        This fixes huge WebHTMLView leaks seen on the leaks bot.
     11
     12        * WebView/WebHTMLView.mm:
     13        (-[WebHTMLViewPrivate dealloc]):
     14        (-[WebHTMLView viewDidMoveToWindow]):
     15
    1162017-01-29  Andy Estes  <aestes@apple.com>
    217
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r211192 r211362  
    10671067    if (promisedDragTIFFDataSource)
    10681068        promisedDragTIFFDataSource->removeClient(promisedDataClient());
     1069
     1070    if (flagsChangedEventMonitor) {
     1071        [NSEvent removeMonitor:flagsChangedEventMonitor];
     1072        flagsChangedEventMonitor = nil;
     1073    }
    10691074#endif
    10701075
     
    35053510#if !PLATFORM(IOS)
    35063511        if (!_private->flagsChangedEventMonitor) {
     3512            __block WebHTMLView *weakSelf = self;
    35073513            _private->flagsChangedEventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskFlagsChanged handler:^(NSEvent *flagsChangedEvent) {
    3508                 [self _postFakeMouseMovedEventForFlagsChangedEvent:flagsChangedEvent];
     3514                [weakSelf _postFakeMouseMovedEventForFlagsChangedEvent:flagsChangedEvent];
    35093515                return flagsChangedEvent;
    35103516            }];
Note: See TracChangeset for help on using the changeset viewer.