Created attachment 208670 [details] proposed patch Any request from the UI process to the Web Content process that is made from a secondary thread will probably fail, because of a bug introduced with Connection::sendSyncMessageFromSecondaryThread() in r139514 (https://bugs.webkit.org/show_bug.cgi?id=106708). It is quite simple: the timeout argument to semaphore.wait() is supposed to be an absolute time, but the length of the timeout is being sent instead.
<rdar://problem/14578770> Thank you, this is a good catch. Note however that we never send sync messages with timeouts from secondary threads. Can you please tell us more about the failing scenario?
Created attachment 208676 [details] patch with ChangeLog
The timeout comes from ChildProcessProxy.h (default argument in ChildProcessProxy::sendSync(), called from UIProcess/mac/WebPageProxyMac.mm). The use case is calling methods of the NSTextInputClient protocol, such as - attributedSubstringForProposedRange:actualRange: on WKView. The secondary thread is running my scripting addition. More details on my scenario (a grammar and spell check application) in bug 61889. It would probably be possible to do the same work using the AppleScript command "do JavaScript" to access the DOM directly. The nice thing about NSTextInputClient is that it conveniently converts back and forth between the DOM and flat attributed strings.
Thank you for the additional information! It's not valid to use NSTextInputClient methods form a secondary thread. We make no attempt to make this work, and in fact do access a lot of shared state from these methods. We should still fix this mistake of course, however I strongly suggest looking into a way to not call -attributedSubstringForProposedRange:actualRange: from secondary threads.
(In reply to comment #4) Ah, that is good to know. I will make my code comply with that restriction. Thank you!
Comment on attachment 208676 [details] patch with ChangeLog Clearing flags on attachment: 208676 Committed r154073: <http://trac.webkit.org/changeset/154073>
All reviewed patches have been landed. Closing bug.