Title: [241094] branches/safari-607-branch/Source/WebKit
Revision
241094
Author
alanc...@apple.com
Date
2019-02-06 14:18:17 -0800 (Wed, 06 Feb 2019)

Log Message

Cherry-pick r240995. rdar://problem/47843415

    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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240995 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (241093 => 241094)


--- branches/safari-607-branch/Source/WebKit/ChangeLog	2019-02-06 22:18:14 UTC (rev 241093)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog	2019-02-06 22:18:17 UTC (rev 241094)
@@ -1,3 +1,46 @@
+2019-02-06  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r240995. rdar://problem/47843415
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-02-05  Tim Horton  <timothy_hor...@apple.com>
+
+            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  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r240928. rdar://problem/47810458

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm (241093 => 241094)


--- branches/safari-607-branch/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm	2019-02-06 22:18:14 UTC (rev 241093)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm	2019-02-06 22:18:17 UTC (rev 241094)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to