Title: [247460] trunk/Source/WebKit
Revision
247460
Author
wenson_hs...@apple.com
Date
2019-07-15 16:09:31 -0700 (Mon, 15 Jul 2019)

Log Message

Followup to r247439
https://bugs.webkit.org/show_bug.cgi?id=199788
<rdar://problem/52142570>

Reviewed by Tim Horton.

As it turns out, sending modern async completion-handler based IPC messages while processing incoming sync
messages results in a debug assertion. Instead of migrating FontAtSelection to the new async IPC mechanism,
restore the older CallbackID-based async IPC.

* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::fontAtSelection):
(WebKit::WebPageProxy::fontAtSelectionCallback):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::fontAtSelection):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (247459 => 247460)


--- trunk/Source/WebKit/ChangeLog	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/ChangeLog	2019-07-15 23:09:31 UTC (rev 247460)
@@ -1,3 +1,25 @@
+2019-07-15  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Followup to r247439
+        https://bugs.webkit.org/show_bug.cgi?id=199788
+        <rdar://problem/52142570>
+
+        Reviewed by Tim Horton.
+
+        As it turns out, sending modern async completion-handler based IPC messages while processing incoming sync
+        messages results in a debug assertion. Instead of migrating FontAtSelection to the new async IPC mechanism,
+        restore the older CallbackID-based async IPC.
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::fontAtSelection):
+        (WebKit::WebPageProxy::fontAtSelectionCallback):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::fontAtSelection):
+
 2019-07-15  Dean Jackson  <d...@apple.com>
 
         [WebGL] Remove software rendering and simplify context creation on macOS

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (247459 => 247460)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-07-15 23:09:31 UTC (rev 247460)
@@ -2810,7 +2810,10 @@
     if (!fontPanelIsVisible && !m_page->editorState().isContentRichlyEditable)
         return;
 
-    m_page->fontAtSelection([](const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts) {
+    m_page->fontAtSelection([](const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts, CallbackBase::Error error) {
+        if (error != CallbackBase::Error::None)
+            return;
+
         NSDictionary *attributeDictionary = (__bridge NSDictionary *)fontInfo.fontAttributeDictionary.get();
         if (!attributeDictionary)
             return;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (247459 => 247460)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2019-07-15 23:09:31 UTC (rev 247460)
@@ -338,6 +338,7 @@
 
 #if PLATFORM(MAC)
 typedef GenericCallback<const AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
+typedef GenericCallback<const FontInfo&, double, bool> FontAtSelectionCallback;
 #endif
 
 #if PLATFORM(IOS_FAMILY)
@@ -788,7 +789,7 @@
 #if PLATFORM(MAC)
     void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>& dictationAlternatives, bool registerUndoGroup);
     void attributedSubstringForCharacterRangeAsync(const EditingRange&, WTF::Function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>&&);
-    void fontAtSelection(Function<void(const FontInfo&, double, bool)>&&);
+    void fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&&);
 
     void startWindowDrag();
     NSWindow *platformWindow();
@@ -1869,6 +1870,7 @@
     void rectForCharacterRangeCallback(const WebCore::IntRect&, const EditingRange&, CallbackID);
 #if PLATFORM(MAC)
     void attributedStringForCharacterRangeCallback(const AttributedString&, const EditingRange&, CallbackID);
+    void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
 #endif
 #if PLATFORM(IOS_FAMILY)
     void gestureCallback(const WebCore::IntPoint&, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (247459 => 247460)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2019-07-15 23:09:31 UTC (rev 247460)
@@ -180,6 +180,7 @@
 #endif
 #if PLATFORM(MAC)
     AttributedStringForCharacterRangeCallback(struct WebKit::AttributedString string, struct WebKit::EditingRange actualRange, WebKit::CallbackID callbackID)
+    FontAtSelectionCallback(struct WebKit::FontInfo fontInfo, double fontSize, bool selectionHasMultipleFonts, WebKit::CallbackID callbackID)
 #endif
     FontAttributesCallback(struct WebCore::FontAttributes attributes, WebKit::CallbackID callbackID)
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (247459 => 247460)


--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2019-07-15 23:09:31 UTC (rev 247460)
@@ -241,15 +241,28 @@
     callback->performCallbackWithReturnValue(string, actualRange);
 }
 
-void WebPageProxy::fontAtSelection(Function<void(const FontInfo&, double, bool)>&& callback)
+void WebPageProxy::fontAtSelection(Function<void(const FontInfo&, double, bool, CallbackBase::Error)>&& callback)
 {
     if (!hasRunningProcess()) {
-        callback({ }, 0, false);
+        callback({ }, 0, false, CallbackBase::Error::Unknown);
         return;
     }
-    m_process->connection()->sendWithAsyncReply(Messages::WebPage::FontAtSelection(), WTFMove(callback), m_pageID);
+
+    auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken());
+    process().send(Messages::WebPage::FontAtSelection(callbackID), m_pageID);
 }
 
+void WebPageProxy::fontAtSelectionCallback(const FontInfo& fontInfo, double fontSize, bool selectionHasMultipleFonts, CallbackID callbackID)
+{
+    auto callback = m_callbacks.take<FontAtSelectionCallback>(callbackID);
+    if (!callback) {
+        // FIXME: Log error or assert.
+        return;
+    }
+
+    callback->performCallbackWithReturnValue(fontInfo, fontSize, selectionHasMultipleFonts);
+}
+
 String WebPageProxy::stringSelectionForPasteboard()
 {
     String value;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (247459 => 247460)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-15 23:09:31 UTC (rev 247460)
@@ -811,7 +811,7 @@
 #if PLATFORM(MAC)
     void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool registerUndoGroup = false);
     void attributedSubstringForCharacterRangeAsync(const EditingRange&, CallbackID);
-    void fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&&);
+    void fontAtSelection(CallbackID);
 #endif
 
 #if PLATFORM(COCOA) && ENABLE(SERVICE_CONTROLS)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (247459 => 247460)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-07-15 23:09:31 UTC (rev 247460)
@@ -445,7 +445,7 @@
 #if PLATFORM(MAC)
     InsertDictatedTextAsync(String text, struct WebKit::EditingRange replacementRange, Vector<WebCore::DictationAlternative> dictationAlternatives, bool registerUndoGroup)
     AttributedSubstringForCharacterRangeAsync(struct WebKit::EditingRange range, WebKit::CallbackID callbackID);
-    FontAtSelection() -> (struct WebKit::FontInfo info, double fontSize, bool hasMultipleFonts) Async
+    FontAtSelection(WebKit::CallbackID callbackID)
 #endif
 
     SetAlwaysShowsHorizontalScroller(bool alwaysShowsHorizontalScroller)

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (247459 => 247460)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2019-07-15 23:06:58 UTC (rev 247459)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2019-07-15 23:09:31 UTC (rev 247460)
@@ -377,35 +377,35 @@
     send(Messages::WebPageProxy::AttributedStringForCharacterRangeCallback(attributedString, rangeToSend, callbackID));
 }
 
-void WebPage::fontAtSelection(CompletionHandler<void(const FontInfo&, double, bool)>&& reply)
+void WebPage::fontAtSelection(CallbackID callbackID)
 {
     bool selectionHasMultipleFonts = false;
     auto& frame = m_page->focusController().focusedOrMainFrame();
 
     if (frame.selection().selection().isNone()) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
     auto* font = frame.editor().fontForSelection(selectionHasMultipleFonts);
     if (!font) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
     auto ctFont = font->getCTFont();
     if (!ctFont) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
     auto fontDescriptor = adoptCF(CTFontCopyFontDescriptor(ctFont));
     if (!fontDescriptor) {
-        reply({ }, 0, false);
+        send(Messages::WebPageProxy::FontAtSelectionCallback({ }, 0, false, callbackID));
         return;
     }
 
-    reply({ adoptCF(CTFontDescriptorCopyAttributes(fontDescriptor.get())) }, CTFontGetSize(ctFont), selectionHasMultipleFonts);
+    send(Messages::WebPageProxy::FontAtSelectionCallback({ adoptCF(CTFontDescriptorCopyAttributes(fontDescriptor.get())) }, CTFontGetSize(ctFont), selectionHasMultipleFonts, callbackID));
 }
     
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to