Bug 167580

Summary: [macOS] WebHTMLView has an internal retain cycle with its flagsChangedEventMonitor.
Product: WebKit Reporter: Andreas Kling <kling>
Component: WebKit APIAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: aestes, commit-queue, kling
Priority: P2 Keywords: Performance
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
koivisto: review+
Patch for landing none

Description Andreas Kling 2017-01-30 02:41:26 PST
There is an internal retain cycle in WebHTMLView:
When initializing _private->flagsChangedEventMonitor, we pass it a block that implicitly captures the WebHTMLView.

This causes WebHTMLViews to leak, they are very visible on the leaks bot.
Comment 1 Andreas Kling 2017-01-30 02:45:03 PST
Created attachment 300093 [details]
Patch

My objective-C is not very strong so please look carefully when reviewing.
Comment 2 Antti Koivisto 2017-01-30 03:06:46 PST
Comment on attachment 300093 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=300093&action=review

> Source/WebKit/mac/WebView/WebHTMLView.mm:3512
> +            _private->flagsChangedEventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskFlagsChanged handler:[self] (NSEvent *flagsChangedEvent) {

I think

__block WebHTMLView *weakSelf = self;

works in pre-arc world.
Comment 3 Andreas Kling 2017-01-30 03:30:47 PST
Created attachment 300095 [details]
Patch for landing
Comment 4 WebKit Commit Bot 2017-01-30 04:08:38 PST
Comment on attachment 300095 [details]
Patch for landing

Clearing flags on attachment: 300095

Committed r211362: <http://trac.webkit.org/changeset/211362>
Comment 5 WebKit Commit Bot 2017-01-30 04:08:41 PST
All reviewed patches have been landed.  Closing bug.