Changeset 242551 in webkit
- Timestamp:
- Mar 6, 2019 9:38:37 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r242550 r242551 1 2019-03-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Frequent 1 second IPC deadlocks when showing a paste callout 4 https://bugs.webkit.org/show_bug.cgi?id=195354 5 <rdar://problem/48624675> 6 7 Reviewed by Tim Horton. 8 9 Most of these tests currently encounter and rely on the 1 second IPC timeout to finish. To test this fix, force 10 `ignoreSynchronousMessagingTimeouts=true` to make them fail if the processes encounter a deadlock. 11 12 * editing/pasteboard/ios/dom-paste-confirmation.html: 13 * editing/pasteboard/ios/dom-paste-consecutive-confirmations.html: 14 * editing/pasteboard/ios/dom-paste-rejection.html: 15 * editing/pasteboard/ios/dom-paste-requires-user-gesture.html: 16 * editing/pasteboard/ios/dom-paste-same-origin.html: 17 1 18 2019-03-06 Javier Fernandez <jfernandez@igalia.com> 2 19 -
trunk/LayoutTests/editing/pasteboard/ios/dom-paste-confirmation.html
r242317 r242551 1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] --> 2 2 <html> 3 3 <meta name="viewport" content="width=device-width, initial-scale=1"> -
trunk/LayoutTests/editing/pasteboard/ios/dom-paste-consecutive-confirmations.html
r242317 r242551 1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] --> 2 2 <html> 3 3 <meta name="viewport" content="width=device-width, initial-scale=1"> -
trunk/LayoutTests/editing/pasteboard/ios/dom-paste-rejection.html
r242317 r242551 1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] --> 2 2 <html> 3 3 <meta name="viewport" content="width=device-width, initial-scale=1"> -
trunk/LayoutTests/editing/pasteboard/ios/dom-paste-requires-user-gesture.html
r242317 r242551 1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] --> 2 2 <html> 3 3 <meta name="viewport" content="width=device-width, initial-scale=1"> -
trunk/LayoutTests/editing/pasteboard/ios/dom-paste-same-origin.html
r242317 r242551 1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ] -->1 <!DOCTYPE html> <!-- webkit-test-runner [ domPasteAllowed=false useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] --> 2 2 <html> 3 3 <meta name="viewport" content="width=device-width, initial-scale=1"> -
trunk/Source/WebKit/ChangeLog
r242534 r242551 1 2019-03-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Frequent 1 second IPC deadlocks when showing a paste callout 4 https://bugs.webkit.org/show_bug.cgi?id=195354 5 <rdar://problem/48624675> 6 7 Reviewed by Tim Horton. 8 9 When triggering programmatic paste, we frequently hit deadlocks due to sync IPC going from the UI process to the 10 web process and vice versa. What happens in this scenario is that prior to triggering programmatic paste, the 11 page may try to move focus to a different element (e.g. a hidden editable area) before calling `execCommand`. 12 This causes us to send an ElementDidFocus message to the UI process, followed by RequestDOMPasteAccess. 13 14 However, upon receiving ElementDidFocus, we reload input views and (in the process) UIKit requests the 15 autocorrection context, which we implement in WebKit using a sync message to the web process due to 16 <rdar://problem/16207002> and its blocking bug <rdar://problem/48383001>. This means we'll end up in a state 17 where both the UI process and web process are blocked on each other waiting for a sync IPC response, and the UI 18 process is hung for a second until the IPC message times out. 19 20 Ideally, we should fix this by addressing <rdar://problem/16207002>. However, this requires potentially large 21 changes in UIKit (<rdar://problem/48383001>); for the time being, work around this deadlock by refactoring 22 synchronous autocorrection context requests such that they can be resolved by an out-of-band IPC response 23 (HandleAutocorrectionContext). Then prior to requesting DOM paste access, preemptively send a 24 HandleAutocorrectionContext message to the UI process to unblock any pending synchronous autocorrection context 25 requests. 26 27 * UIProcess/PageClient.h: 28 * UIProcess/WebPageProxy.h: 29 * UIProcess/WebPageProxy.messages.in: 30 * UIProcess/ios/PageClientImplIOS.h: 31 * UIProcess/ios/PageClientImplIOS.mm: 32 (WebKit::PageClientImpl::handleAutocorrectionContext): 33 * UIProcess/ios/WKContentViewInteraction.h: 34 35 Make it possible for WKContentView to remember its current pending autocorrection context completion handler. 36 This is invoked and cleared out in `-_invokePendingAutocorrectionContextHandler:`. 37 38 * UIProcess/ios/WKContentViewInteraction.mm: 39 (-[WKContentView _invokePendingAutocorrectionContextHandler:]): 40 (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]): 41 (-[WKContentView _handleAutocorrectionContext:]): 42 43 Handle an autocorrection context response. This is invoked when the web process either handles an autocorrection 44 context message, or when it preemptively sends an autocorrection context before requesting DOM paste access. 45 46 (+[WKAutocorrectionContext emptyAutocorrectionContext]): 47 48 Add a helper to create an empty autocorrection context. 49 50 * UIProcess/ios/WebPageProxyIOS.mm: 51 (WebKit::WebPageProxy::requestAutocorrectionContext): 52 (WebKit::WebPageProxy::handleAutocorrectionContext): 53 (WebKit::WebPageProxy::autocorrectionContextSync): Deleted. 54 55 Removed this sync version, since we now only have requestAutocorrectionContext. 56 57 * WebProcess/WebPage/WebPage.cpp: 58 (WebKit::WebPage::requestDOMPasteAccess): 59 60 Send WebPageProxy::HandleAutocorrectionContext, and add a FIXME referencing <rdar://problem/16207002>. 61 62 * WebProcess/WebPage/WebPage.h: 63 * WebProcess/WebPage/WebPage.messages.in: 64 65 Split AutocorrectionContextSync into RequestAutocorrectionContext and HandleAutocorrectionContext; additionally, 66 remove the existing RequestAutocorrectionContext message. 67 68 * WebProcess/WebPage/ios/WebPageIOS.mm: 69 (WebKit::WebPage::requestAutocorrectionContext): 70 (WebKit::WebPage::autocorrectionContextSync): Deleted. 71 1 72 2019-03-06 Rob Buis <rbuis@igalia.com> 2 73 -
trunk/Source/WebKit/UIProcess/PageClient.h
r242339 r242551 131 131 struct FocusedElementInformation; 132 132 struct InteractionInformationAtPosition; 133 struct WebAutocorrectionContext; 133 134 struct WebHitTestResultData; 134 135 … … 395 396 virtual void enableInspectorNodeSearch() = 0; 396 397 virtual void disableInspectorNodeSearch() = 0; 398 399 virtual void handleAutocorrectionContext(const WebAutocorrectionContext&) = 0; 397 400 #endif 398 401 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r242400 r242551 651 651 void applyAutocorrection(const String& correction, const String& originalText, WTF::Function<void (const String&, CallbackBase::Error)>&&); 652 652 bool applyAutocorrection(const String& correction, const String& originalText); 653 void requestAutocorrectionContext( Function<void(const WebAutocorrectionContext&, CallbackBase::Error)>&&);654 WebAutocorrectionContext autocorrectionContextSync();653 void requestAutocorrectionContext(); 654 void handleAutocorrectionContext(const WebAutocorrectionContext&); 655 655 void requestDictationContext(WTF::Function<void (const String&, const String&, const String&, CallbackBase::Error)>&&); 656 656 void replaceDictatedText(const String& oldText, const String& newText); -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r242317 r242551 418 418 419 419 UpdateStringForFind(String findString) 420 HandleAutocorrectionContext(struct WebKit::WebAutocorrectionContext context) 420 421 #endif 421 422 -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h
r242317 r242551 237 237 #endif 238 238 239 void handleAutocorrectionContext(const WebAutocorrectionContext&) final; 240 239 241 void didFinishProcessingAllPendingMouseEvents() final { } 240 242 -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
r242317 r242551 858 858 #endif 859 859 860 void PageClientImpl::handleAutocorrectionContext(const WebAutocorrectionContext& context) 861 { 862 [m_contentView _handleAutocorrectionContext:context]; 863 } 864 860 865 } // namespace WebKit 861 866 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r242317 r242551 86 86 class WebOpenPanelResultListenerProxy; 87 87 class WebPageProxy; 88 struct WebAutocorrectionContext; 88 89 } 89 90 … … 319 320 BOOL _hasSetUpInteractions; 320 321 CompletionHandler<void(WebCore::DOMPasteAccessResponse)> _domPasteRequestHandler; 322 BlockPtr<void(UIWKAutocorrectionContext *)> _pendingAutocorrectionContextHandler; 321 323 322 324 #if ENABLE(DATA_INTERACTION) … … 466 468 #endif 467 469 470 - (void)_handleAutocorrectionContext:(const WebKit::WebAutocorrectionContext&)context; 471 468 472 @end 469 473 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r242400 r242551 277 277 278 278 @interface WKAutocorrectionContext : UIWKAutocorrectionContext 279 + (WKAutocorrectionContext *)emptyAutocorrectionContext; 279 280 + (WKAutocorrectionContext *)autocorrectionContextWithContext:(const WebKit::WebAutocorrectionContext&)context; 280 281 @end … … 3580 3581 } 3581 3582 3583 - (void)_invokePendingAutocorrectionContextHandler:(WKAutocorrectionContext *)context 3584 { 3585 if (auto handler = WTFMove(_pendingAutocorrectionContextHandler)) 3586 handler(context); 3587 } 3588 3582 3589 - (void)requestAutocorrectionContextWithCompletionHandler:(void (^)(UIWKAutocorrectionContext *autocorrectionContext))completionHandler 3583 3590 { … … 3589 3596 #if USE(UIKIT_KEYBOARD_ADDITIONS) 3590 3597 if ([self _disableAutomaticKeyboardUI]) { 3591 completionHandler( [WKAutocorrectionContext autocorrectionContextWithContext:(WebKit::WebAutocorrectionContext { })]);3598 completionHandler(WKAutocorrectionContext.emptyAutocorrectionContext); 3592 3599 return; 3593 3600 } … … 3597 3604 const bool useSyncRequest = true; 3598 3605 3606 [self _invokePendingAutocorrectionContextHandler:WKAutocorrectionContext.emptyAutocorrectionContext]; 3607 3608 _pendingAutocorrectionContextHandler = completionHandler; 3609 _page->requestAutocorrectionContext(); 3610 3599 3611 if (useSyncRequest) { 3600 completionHandler([WKAutocorrectionContext autocorrectionContextWithContext:_page->autocorrectionContextSync()]); 3601 return; 3602 } 3603 3604 _page->requestAutocorrectionContext([protectedSelf = retainPtr(self), completion = makeBlockPtr(completionHandler)] (auto& context, auto) { 3605 completion([WKAutocorrectionContext autocorrectionContextWithContext:context]); 3606 }); 3612 _page->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::HandleAutocorrectionContext>(_page->pageID(), 1_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives); 3613 [self _invokePendingAutocorrectionContextHandler:WKAutocorrectionContext.emptyAutocorrectionContext]; 3614 return; 3615 } 3616 } 3617 3618 - (void)_handleAutocorrectionContext:(const WebKit::WebAutocorrectionContext&)context 3619 { 3620 [self _invokePendingAutocorrectionContextHandler:[WKAutocorrectionContext autocorrectionContextWithContext:context]]; 3607 3621 } 3608 3622 … … 7411 7425 @implementation WKAutocorrectionContext 7412 7426 7427 + (WKAutocorrectionContext *)emptyAutocorrectionContext 7428 { 7429 return [self autocorrectionContextWithContext:WebKit::WebAutocorrectionContext { }]; 7430 } 7431 7413 7432 + (WKAutocorrectionContext *)autocorrectionContextWithContext:(const WebKit::WebAutocorrectionContext&)webContext 7414 7433 { -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r242400 r242551 564 564 } 565 565 566 void WebPageProxy::requestAutocorrectionContext(Function<void(const WebAutocorrectionContext&, CallbackBase::Error)>&& callback) 567 { 568 if (!isValid()) { 569 callback({ }, CallbackBase::Error::OwnerWasInvalidated); 570 return; 571 } 572 573 auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivityToken()); 574 m_process->send(Messages::WebPage::RequestAutocorrectionContext(callbackID), m_pageID); 575 } 576 577 WebAutocorrectionContext WebPageProxy::autocorrectionContextSync() 578 { 579 WebAutocorrectionContext context; 580 m_process->sendSync(Messages::WebPage::AutocorrectionContextSync(), Messages::WebPage::AutocorrectionContextSync::Reply(context), m_pageID); 581 return context; 566 void WebPageProxy::requestAutocorrectionContext() 567 { 568 m_process->send(Messages::WebPage::RequestAutocorrectionContext(), m_pageID); 569 } 570 571 void WebPageProxy::handleAutocorrectionContext(const WebAutocorrectionContext& context) 572 { 573 pageClient().handleAutocorrectionContext(context); 582 574 } 583 575 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r242468 r242551 269 269 #include "InteractionInformationRequest.h" 270 270 #include "RemoteLayerTreeDrawingArea.h" 271 #include "WebAutocorrectionContext.h" 271 272 #include <CoreGraphics/CoreGraphics.h> 272 273 #include <WebCore/Icon.h> … … 6374 6375 { 6375 6376 auto response = WebCore::DOMPasteAccessResponse::DeniedForGesture; 6377 #if PLATFORM(IOS_FAMILY) 6378 // FIXME: Computing and sending an autocorrection context is a workaround for the fact that autocorrection context 6379 // requests on iOS are currently synchronous in the web process. This allows us to immediately fulfill pending 6380 // autocorrection context requests in the UI process on iOS before handling the DOM paste request. This workaround 6381 // should be removed once <rdar://problem/16207002> is resolved. 6382 send(Messages::WebPageProxy::HandleAutocorrectionContext(autocorrectionContext())); 6383 #endif 6376 6384 sendSyncWithDelayedReply(Messages::WebPageProxy::RequestDOMPasteAccess(rectForElementAtInteractionLocation(), originIdentifier), Messages::WebPageProxy::RequestDOMPasteAccess::Reply(response)); 6377 6385 return response; -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r242468 r242551 642 642 void applyAutocorrection(const String& correction, const String& originalText, CallbackID); 643 643 void syncApplyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(bool)>&&); 644 void requestAutocorrectionContext(CallbackID); 645 void autocorrectionContextSync(CompletionHandler<void(WebAutocorrectionContext&&)>&&); 644 void requestAutocorrectionContext(); 646 645 void getPositionInformation(const InteractionInformationRequest&, CompletionHandler<void(InteractionInformationAtPosition&&)>&&); 647 646 void requestPositionInformation(const InteractionInformationRequest&); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r242400 r242551 79 79 ApplyAutocorrection(String correction, String originalText, WebKit::CallbackID callbackID) 80 80 SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied) Delayed 81 RequestAutocorrectionContext(WebKit::CallbackID callbackID) 82 AutocorrectionContextSync() -> (struct WebKit::WebAutocorrectionContext context) Delayed 81 RequestAutocorrectionContext() 83 82 RequestEvasionRectsAboveSelection() -> (Vector<WebCore::FloatRect> rects) Async 84 83 GetPositionInformation(struct WebKit::InteractionInformationRequest request) -> (struct WebKit::InteractionInformationAtPosition information) Delayed -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r242467 r242551 2158 2158 } 2159 2159 2160 void WebPage::requestAutocorrectionContext(CallbackID callbackID) 2161 { 2162 send(Messages::WebPageProxy::AutocorrectionContextCallback(autocorrectionContext(), callbackID)); 2163 } 2164 2165 void WebPage::autocorrectionContextSync(CompletionHandler<void(WebAutocorrectionContext&&)>&& completionHandler) 2166 { 2167 completionHandler(autocorrectionContext()); 2160 void WebPage::requestAutocorrectionContext() 2161 { 2162 send(Messages::WebPageProxy::HandleAutocorrectionContext(autocorrectionContext())); 2168 2163 } 2169 2164
Note: See TracChangeset
for help on using the changeset viewer.