<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>119767</bug_id>
          
          <creation_ts>2013-08-13 13:49:44 -0700</creation_ts>
          <short_desc>[WK2] Sync messages with non-default timeout sent from secondary threads always time out</short_desc>
          <delta_ts>2013-08-14 14:35:48 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit2</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.8</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Justin Bur">justin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>commit-queue</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>916862</commentid>
    <comment_count>0</comment_count>
      <attachid>208670</attachid>
    <who name="Justin Bur">justin</who>
    <bug_when>2013-08-13 13:49:44 -0700</bug_when>
    <thetext>Created attachment 208670
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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>916881</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-08-13 14:17:42 -0700</bug_when>
    <thetext>&lt;rdar://problem/14578770&gt;

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?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>916885</commentid>
    <comment_count>2</comment_count>
      <attachid>208676</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-08-13 14:24:23 -0700</bug_when>
    <thetext>Created attachment 208676
patch with ChangeLog</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>916926</commentid>
    <comment_count>3</comment_count>
    <who name="Justin Bur">justin</who>
    <bug_when>2013-08-13 15:54:06 -0700</bug_when>
    <thetext>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 &quot;do JavaScript&quot; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>916950</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-08-13 17:05:31 -0700</bug_when>
    <thetext>Thank you for the additional information!

It&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>916962</commentid>
    <comment_count>5</comment_count>
    <who name="Justin Bur">justin</who>
    <bug_when>2013-08-13 17:27:16 -0700</bug_when>
    <thetext>(In reply to comment #4)
Ah, that is good to know. I will make my code comply with that restriction. Thank you!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>917292</commentid>
    <comment_count>6</comment_count>
      <attachid>208676</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-08-14 14:35:46 -0700</bug_when>
    <thetext>Comment on attachment 208676
patch with ChangeLog

Clearing flags on attachment: 208676

Committed r154073: &lt;http://trac.webkit.org/changeset/154073&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>917293</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-08-14 14:35:48 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>208670</attachid>
            <date>2013-08-13 13:49:44 -0700</date>
            <delta_ts>2013-08-13 14:24:23 -0700</delta_ts>
            <desc>proposed patch</desc>
            <filename>CoreIPC-Connection.cpp.patch</filename>
            <type>text/plain</type>
            <size>494</size>
            <attacher name="Justin Bur">justin</attacher>
            
              <data encoding="base64">LS0tIFdlYktpdC1yMTUzODgyL1NvdXJjZS9XZWJLaXQyL1BsYXRmb3JtL0NvcmVJUEMvQ29ubmVj
dGlvbi5jcHAJMjAxMy0wNy0zMCAyMToxMzoyMS4wMDAwMDAwMDAgLTA0MDAKKysrIFdlYktpdC1y
MTUzODgyL1NvdXJjZS9XZWJLaXQyL1BsYXRmb3JtL0NvcmVJUEMvQ29ubmVjdGlvbisuY3BwCTIw
MTMtMDgtMTMgMTY6MzA6MzUuMDAwMDAwMDAwIC0wNDAwCkBAIC01MTEsNyArNTExLDkgQEAKICAg
ICBpZiAodGltZW91dCA9PSBOb1RpbWVvdXQpCiAgICAgICAgIHRpbWVvdXQgPSAxZTEwOwogCi0g
ICAgcGVuZGluZ1JlcGx5LnNlbWFwaG9yZS53YWl0KHRpbWVvdXQpOworICAgIGRvdWJsZSBhYnNv
bHV0ZVRpbWUgPSBjdXJyZW50VGltZSgpICsgdGltZW91dDsKKworICAgIHBlbmRpbmdSZXBseS5z
ZW1hcGhvcmUud2FpdChhYnNvbHV0ZVRpbWUpOwogCiAgICAgLy8gRmluYWxseSwgcG9wIHRoZSBw
ZW5kaW5nIHN5bmMgcmVwbHkgaW5mb3JtYXRpb24uCiAgICAgewo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>208676</attachid>
            <date>2013-08-13 14:24:23 -0700</date>
            <delta_ts>2013-08-14 14:35:46 -0700</delta_ts>
            <desc>patch with ChangeLog</desc>
            <filename>timeout.txt</filename>
            <type>text/plain</type>
            <size>1367</size>
            <attacher name="Alexey Proskuryakov">ap</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJLaXQyL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
S2l0Mi9DaGFuZ2VMb2cJKHJldmlzaW9uIDE1NDAyMikKKysrIFNvdXJjZS9XZWJLaXQyL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE1IEBACisyMDEzLTA4LTEzICBBbGV4ZXkg
UHJvc2t1cnlha292ICA8YXBAYXBwbGUuY29tPgorCisgICAgICAgIFtXSzJdIFN5bmMgbWVzc2Fn
ZXMgd2l0aCB3aXRoIG5vbi1kZWZhdWx0IHRpbWVvdXQgc2VudCBmcm9tIHNlY29uZGFyeSB0aHJl
YWRzIGFsd2F5cyB0aW1lIG91dAorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93
X2J1Zy5jZ2k/aWQ9MTE5NzY3CisKKyAgICAgICAgRml4IGJ5IEp1c3RpbiBCdXIuCisgICAgICAg
IFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgICogUGxhdGZvcm0vQ29yZUlQ
Qy9Db25uZWN0aW9uLmNwcDogKEN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wbHkgaW5mb3JtYXRpb24uCiAgICAgewo=
</data>

          </attachment>
      

    </bug>

</bugzilla>