Title: [231893] trunk/Source/WebKit
Revision
231893
Author
d...@apple.com
Date
2018-05-17 04:30:04 -0700 (Thu, 17 May 2018)

Log Message

Safari optimized flow should be releasing viewer to prevent memory growth with subsequent launches/closes
https://bugs.webkit.org/show_bug.cgi?id=185722
<rdar://problem/40247351>

Reviewed by Antoine Quint.

I made a rookie mistake in the original patch: I was holding a strong
reference to "self" in a block, which was causing a retain cycle.
Replace that with a WeakObjCPtr.

* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (231892 => 231893)


--- trunk/Source/WebKit/ChangeLog	2018-05-17 10:17:28 UTC (rev 231892)
+++ trunk/Source/WebKit/ChangeLog	2018-05-17 11:30:04 UTC (rev 231893)
@@ -1,3 +1,18 @@
+2018-05-17  Dean Jackson  <d...@apple.com>
+
+        Safari optimized flow should be releasing viewer to prevent memory growth with subsequent launches/closes
+        https://bugs.webkit.org/show_bug.cgi?id=185722
+        <rdar://problem/40247351>
+
+        Reviewed by Antoine Quint.
+
+        I made a rookie mistake in the original patch: I was holding a strong
+        reference to "self" in a block, which was causing a retain cycle.
+        Replace that with a WeakObjCPtr.
+
+        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+        (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]):
+
 2018-05-16  Brent Fulgham  <bfulg...@apple.com>
 
         REGRESSION(r229093)[macOS] Allow network-outbound for syslog use

Modified: trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm (231892 => 231893)


--- trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm	2018-05-17 10:17:28 UTC (rev 231892)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm	2018-05-17 11:30:04 UTC (rev 231893)
@@ -29,8 +29,8 @@
 #if USE(SYSTEM_PREVIEW)
 
 #import "APIUIClient.h"
+#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
-
 #import <MobileCoreServices/MobileCoreServices.h>
 #import <QuickLook/QuickLook.h>
 #import <UIKit/UIViewController.h>
@@ -87,9 +87,10 @@
     _item = adoptNS([allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]);
     [_item setUseLoadingTimeout:NO];
 
-    [_itemProvider registerItemForTypeIdentifier:contentType loadHandler:^(NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) {
-        // This will get called once the download completes.
-        self.completionHandler = completionHandler;
+    WebKit::WeakObjCPtr<_WKPreviewControllerDataSource> weakSelf { self };
+    [_itemProvider registerItemForTypeIdentifier:contentType loadHandler:[weakSelf = WTFMove(weakSelf)] (NSItemProviderCompletionHandler completionHandler, Class expectedValueClass, NSDictionary * options) {
+        if (auto strongSelf = weakSelf.get())
+            [strongSelf setCompletionHandler:completionHandler];
     }];
     return _item.get();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to