Bug 167580 - [macOS] WebHTMLView has an internal retain cycle with its flagsChangedEventMonitor.
Summary: [macOS] WebHTMLView has an internal retain cycle with its flagsChangedEventMo...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords: Performance
Depends on:
Blocks:
 
Reported: 2017-01-30 02:41 PST by Andreas Kling
Modified: 2017-01-30 04:08 PST (History)
3 users (show)

See Also:


Attachments
Patch (1.96 KB, patch)
2017-01-30 02:45 PST, Andreas Kling
koivisto: review+
Details | Formatted Diff | Diff
Patch for landing (2.06 KB, patch)
2017-01-30 03:30 PST, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.