Changeset 244400 in webkit
- Timestamp:
- Apr 17, 2019 1:20:40 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244392 r244400 1 2019-04-17 Tim Horton <timothy_horton@apple.com> 2 3 UI↔Web deadlock when printing with a JavaScript alert visible 4 https://bugs.webkit.org/show_bug.cgi?id=196839 5 <rdar://problem/49157642> 6 7 Reviewed by Andy Estes. 8 9 * Platform/IPC/Connection.cpp: 10 (IPC::Connection::dispatchWorkQueueMessageReceiverMessage): 11 (IPC::Connection::sendSyncReply): 12 (IPC::Connection::dispatchSyncMessage): 13 * Platform/IPC/Connection.h: 14 (IPC::Connection::hasOutstandingOutgoingSynchronousReplies const): 15 Keep track of whether we owe the other side of the connection any 16 delayed sync replies. 17 18 * UIProcess/API/Cocoa/WKWebView.mm: 19 (-[WKWebView _webViewPrintFormatter]): 20 Most actions one can take with a _WKWebViewPrintFormatter involve 21 synchronously messaging the Web Content process with an infinite timeout. 22 Doing so while the Web Content process is awaiting a reply to a deferred-reply 23 synchronous message (like, say, an alert()) results in an app-destroying deadlock. 24 Instead of that, return a nil _WKWebViewPrintFormatter, indicating to the client 25 that we can't print right now. 26 27 * UIProcess/ios/WKContentView.mm: 28 (-[WKContentView _wk_pageCountForPrintFormatter:]): 29 (-[WKContentView _wk_printedDocument]): 30 The above isn't sufficient, though, because a sync message could arrive and 31 be handled between creation and use of the _WKWebViewPrintFormatter. 32 So, we also bail with a zero page count and null CGPDFDocument immediately 33 before we would send a sync message to the Web Content process. Clients 34 handle this less gracefully (e.g. showing a zero page PDF), but it is 35 very rare compared to the above case. 36 1 37 2019-04-17 Zalan Bujtas <zalan@apple.com> 2 38 -
trunk/Source/WebKit/Platform/IPC/Connection.cpp
r243345 r244400 342 342 } 343 343 344 m_outstandingOutgoingSynchronousReplyCount++; 345 344 346 auto replyEncoder = std::make_unique<Encoder>("IPC", "SyncMessageReply", syncRequestID); 345 347 … … 459 461 bool Connection::sendSyncReply(std::unique_ptr<Encoder> encoder) 460 462 { 463 ASSERT(m_outstandingOutgoingSynchronousReplyCount); 464 m_outstandingOutgoingSynchronousReplyCount--; 465 461 466 return sendMessage(WTFMove(encoder), { }); 462 467 } … … 889 894 } 890 895 896 m_outstandingOutgoingSynchronousReplyCount++; 897 891 898 auto replyEncoder = std::make_unique<Encoder>("IPC", "SyncMessageReply", syncRequestID); 892 899 -
trunk/Source/WebKit/Platform/IPC/Connection.h
r244091 r244400 197 197 bool inSendSync() const { return m_inSendSyncCount; } 198 198 199 bool hasOutstandingOutgoingSynchronousReplies() const { return m_outstandingOutgoingSynchronousReplyCount; } 200 199 201 Identifier identifier() const; 200 202 … … 298 300 unsigned m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount; 299 301 unsigned m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting { 0 }; 302 unsigned m_outstandingOutgoingSynchronousReplyCount { 0 }; 300 303 bool m_fullySynchronousModeIsAllowedForTesting { false }; 301 304 bool m_ignoreTimeoutsForTesting { false }; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r244370 r244400 6324 6324 { 6325 6325 #if !PLATFORM(IOSMAC) 6326 if (_page->process().connection()->hasOutstandingOutgoingSynchronousReplies()) 6327 return nil; 6328 6326 6329 UIViewPrintFormatter *viewPrintFormatter = self.viewPrintFormatter; 6327 6330 ASSERT([viewPrintFormatter isKindOfClass:[_WKWebViewPrintFormatter class]]); -
trunk/Source/WebKit/UIProcess/ios/WKContentView.mm
r244085 r244400 727 727 return 0; 728 728 729 if (_page->process().connection()->hasOutstandingOutgoingSynchronousReplies()) 730 return 0; 731 729 732 uint64_t frameID; 730 733 if (_WKFrameHandle *handle = printFormatter.frameToPrint) … … 770 773 - (CGPDFDocumentRef)_wk_printedDocument 771 774 { 775 if (_page->process().connection()->hasOutstandingOutgoingSynchronousReplies()) 776 return nullptr; 777 772 778 if (_isPrintingToPDF) { 773 779 if (!_page->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DrawToPDFCallback>(_page->pageID(), Seconds::infinity())) { -
trunk/Tools/ChangeLog
r244390 r244400 1 2019-04-17 Tim Horton <timothy_horton@apple.com> 2 3 UI↔Web deadlock when printing with a JavaScript alert visible 4 https://bugs.webkit.org/show_bug.cgi?id=196839 5 <rdar://problem/49157642> 6 7 Reviewed by Andy Estes. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewPrintFormatter.mm: Added. 11 (-[PrintOnAlertUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 12 (TEST): 13 1 14 2019-04-17 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r244361 r244400 95 95 2D2BEB2D22324E5F005544CA /* RequestTextInputContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2BEB2C22324E5F005544CA /* RequestTextInputContext.mm */; }; 96 96 2D3CA3A8221DF4B40088E803 /* PageOverlayPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D3CA3A4221DF2390088E803 /* PageOverlayPlugin.mm */; }; 97 2D41CFB92260014F00FFF335 /* WKWebViewPrintFormatter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D41CFB82260014E00FFF335 /* WKWebViewPrintFormatter.mm */; }; 97 98 2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */; }; 98 99 2D51A0C71C8BF00C00765C45 /* DOMHTMLVideoElementWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */; }; … … 1451 1452 2D2BEB2C22324E5F005544CA /* RequestTextInputContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RequestTextInputContext.mm; sourceTree = "<group>"; }; 1452 1453 2D3CA3A4221DF2390088E803 /* PageOverlayPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageOverlayPlugin.mm; sourceTree = "<group>"; }; 1454 2D41CFB82260014E00FFF335 /* WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewPrintFormatter.mm; sourceTree = "<group>"; }; 1453 1455 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKThumbnailView.mm; path = WebKit/WKThumbnailView.mm; sourceTree = "<group>"; }; 1454 1456 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLVideoElementWrapper.mm; sourceTree = "<group>"; }; … … 2715 2717 F4106C6821ACBF84004B89A1 /* WKWebViewFirstResponderTests.mm */, 2716 2718 D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */, 2719 2D41CFB82260014E00FFF335 /* WKWebViewPrintFormatter.mm */, 2717 2720 37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */, 2718 2721 93F56DA81E5F9181003EDE84 /* WKWebViewSnapshot.mm */, … … 4447 4450 D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */, 4448 4451 F4FA91811E61849B007B8C1D /* WKWebViewMacEditingTests.mm in Sources */, 4452 2D41CFB92260014F00FFF335 /* WKWebViewPrintFormatter.mm in Sources */, 4449 4453 37A9DBE9213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm in Sources */, 4450 4454 93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.