Title: [240995] trunk/Source/WebKit
Revision
240995
Author
[email protected]
Date
2019-02-05 15:01:04 -0800 (Tue, 05 Feb 2019)

Log Message

Reproducible crash under WKShareSheet presentWithParameters when cancelling a share
https://bugs.webkit.org/show_bug.cgi?id=194301
<rdar://problem/47719379>

Reviewed by Beth Dakin.

* UIProcess/Cocoa/WKShareSheet.mm:
(-[WKShareSheet presentWithParameters:completionHandler:]):
NSSharingServicePicker's delegate callbacks can be called synchronously.
We release the WKShareSheet (which holds our reference to the NSSharingServicePicker)
under sharingServicePicker:didChooseSharingService:. On older versions of macOS,
there was nothing keeping the NSSharingServicePicker alive inside
showRelativeToRect:ofView:preferredEdge:, thus the whole chain of references would
fall and result in sending a message to a released NSSharingServicePicker.
To resolve this, keep an extra reference to the WKShareSheet until
presentation is complete.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (240994 => 240995)


--- trunk/Source/WebKit/ChangeLog	2019-02-05 22:58:19 UTC (rev 240994)
+++ trunk/Source/WebKit/ChangeLog	2019-02-05 23:01:04 UTC (rev 240995)
@@ -1,3 +1,22 @@
+2019-02-05  Tim Horton  <[email protected]>
+
+        Reproducible crash under WKShareSheet presentWithParameters when cancelling a share
+        https://bugs.webkit.org/show_bug.cgi?id=194301
+        <rdar://problem/47719379>
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/Cocoa/WKShareSheet.mm:
+        (-[WKShareSheet presentWithParameters:completionHandler:]):
+        NSSharingServicePicker's delegate callbacks can be called synchronously.
+        We release the WKShareSheet (which holds our reference to the NSSharingServicePicker)
+        under sharingServicePicker:didChooseSharingService:. On older versions of macOS,
+        there was nothing keeping the NSSharingServicePicker alive inside
+        showRelativeToRect:ofView:preferredEdge:, thus the whole chain of references would
+        fall and result in sending a message to a released NSSharingServicePicker.
+        To resolve this, keep an extra reference to the WKShareSheet until
+        presentation is complete.
+
 2019-02-05  Keith Rollin  <[email protected]>
 
         Enable the automatic checking and regenerations of .xcfilelists during builds

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm (240994 => 240995)


--- trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm	2019-02-05 22:58:19 UTC (rev 240994)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm	2019-02-05 23:01:04 UTC (rev 240995)
@@ -101,6 +101,9 @@
     _sharingServicePicker = adoptNS([[NSSharingServicePicker alloc] initWithItems:shareDataArray.get()]);
     _sharingServicePicker.get().delegate = self;
     
+    // WKShareSheet can be released under NSSharingServicePicker delegate callbacks.
+    RetainPtr<WKShareSheet> protector(self);
+    
     NSPoint location = [NSEvent mouseLocation];
     NSRect mouseLocationRect = NSMakeRect(location.x, location.y, 1.0, 1.0);
     NSRect mouseLocationInWindow = [webView.window convertRectFromScreen:mouseLocationRect];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to