<?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>141189</bug_id>
          
          <creation_ts>2015-02-02 21:13:38 -0800</creation_ts>
          <short_desc>Web Inspector: ASSERT mainThreadPthread launching remote debuggable JSContext app with Debug JavaScriptCore</short_desc>
          <delta_ts>2015-02-03 12:23:47 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>DoNotImportToRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Joseph Pecoraro">joepeck</assigned_to>
          <cc>ggaren</cc>
    
    <cc>graouts</cc>
    
    <cc>joepeck</cc>
    
    <cc>jonowells</cc>
    
    <cc>mattbaker</cc>
    
    <cc>msaboff</cc>
    
    <cc>nvasilyev</cc>
    
    <cc>timothy</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1066354</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-02-02 21:13:38 -0800</bug_when>
    <thetext>* SUMMARY
ASSERT mainThreadPthread launching remote debuggable JSContext app with Debug JavaScriptCore.

    ASSERTION FAILED: mainThreadPthread
    /Users/pecoraro/Code/safari/OpenSource/Source/WTF/wtf/mac/MainThreadMac.mm(206) : bool WTF::isMainThread()
    1   0x100819d40 WTFCrash
    2   0x10084374c WTF::isMainThread()
    3   0x100866271 WTF::StringImpl::createCFString()
    4   0x1008667f4 WTF::StringImpl::operator NSString*()
    5   0x100759cc7 WTF::String::operator NSString*() const
    6   0x100758a8a Inspector::RemoteInspector::listingForDebuggable(Inspector::RemoteInspectorDebuggableInfo const&amp;) const
    7   0x100758f9c Inspector::RemoteInspector::pushListingNow()
    8   0x100758289 Inspector::RemoteInspector::receivedGetListingMessage(NSDictionary*)
    9   0x100757820 Inspector::RemoteInspector::xpcConnectionReceivedMessage(Inspector::RemoteInspectorXPCConnection*, NSString*, NSDictionary*)
    10  0x100765dc8 Inspector::RemoteInspectorXPCConnection::handleEvent(void*)
    ...

This is because WTF::initializeMainThread() hasn&apos;t happened yet, which initializes mainThreadPthread. It must be called from the main thread.

Lets just do it before we auto-start the RemoteInspector::singleton.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066355</commentid>
    <comment_count>1</comment_count>
      <attachid>245924</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-02-02 21:15:59 -0800</bug_when>
    <thetext>Created attachment 245924
[PATCH] Proposed Fix

I have tested on OS X (JSContext, Safari). I will need to test iOS (JSContext, UIWebView) before landing, so marking as cq- for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066356</commentid>
    <comment_count>2</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-02-02 21:16:25 -0800</bug_when>
    <thetext>&lt;rdar://problem/17721044&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066362</commentid>
    <comment_count>3</comment_count>
      <attachid>245924</attachid>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2015-02-02 21:35:56 -0800</bug_when>
    <thetext>Comment on attachment 245924
[PATCH] Proposed Fix

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066500</commentid>
    <comment_count>4</comment_count>
      <attachid>245924</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2015-02-03 11:04:13 -0800</bug_when>
    <thetext>Comment on attachment 245924
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=245924&amp;action=review

&gt; Source/JavaScriptCore/inspector/remote/RemoteInspector.mm:91
&gt; +                    shared.get().start();

I believe that start() used to be called on the XPC queue, and now will be called on the main queue.

I think it would be slightly better to dispatch *again* inside the main queue block *back* to the XPC queue in order to call start().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066511</commentid>
    <comment_count>5</comment_count>
      <attachid>245924</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-02-03 11:34:06 -0800</bug_when>
    <thetext>Comment on attachment 245924
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=245924&amp;action=review

&gt;&gt; Source/JavaScriptCore/inspector/remote/RemoteInspector.mm:91
&gt;&gt; +                    shared.get().start();
&gt; 
&gt; I believe that start() used to be called on the XPC queue, and now will be called on the main queue.
&gt; 
&gt; I think it would be slightly better to dispatch *again* inside the main queue block *back* to the XPC queue in order to call start().

start() was getting called on whatever queue/thread first called RemoteInspector::singleton. Often, that is whatever queue/thread created the first JSContext/WebCore::Page/

It is thread safe and can be called from any queue:

  void RemoteInspector::start()
  {
      std::lock_guard&lt;std::mutex&gt; lock(m_mutex);
      ...
  }

Is your concern that we should do work off the main queue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066515</commentid>
    <comment_count>6</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2015-02-03 11:40:45 -0800</bug_when>
    <thetext>&gt; start() was getting called on whatever queue/thread first called
&gt; RemoteInspector::singleton. Often, that is whatever queue/thread created the
&gt; first JSContext/WebCore::Page/

Okeedokee.

&gt; Is your concern that we should do work off the main queue?

I&apos;m not necessarily concerned that we must work off the main queue; I was just observing (possibly incorrectly) that the previous code seemed to avoid the startup on the main queue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066518</commentid>
    <comment_count>7</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-02-03 11:46:18 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; &gt; start() was getting called on whatever queue/thread first called
&gt; &gt; RemoteInspector::singleton. Often, that is whatever queue/thread created the
&gt; &gt; first JSContext/WebCore::Page/
&gt; 
&gt; Okeedokee.
&gt; 
&gt; &gt; Is your concern that we should do work off the main queue?
&gt; 
&gt; I&apos;m not necessarily concerned that we must work off the main queue; I was
&gt; just observing (possibly incorrectly) that the previous code seemed to avoid
&gt; the startup on the main queue.

Ahh, okay. It was doing the work on whatever queue it was given. Originally I had it do WTF::initializeMainThread(), which was incorrect if it was initialized on a non-main queue. Now I&apos;m just biting the bullet and always doing it on the main queue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066524</commentid>
    <comment_count>8</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-02-03 12:23:47 -0800</bug_when>
    <thetext>http://trac.webkit.org/changeset/179562</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>245924</attachid>
            <date>2015-02-02 21:15:59 -0800</date>
            <delta_ts>2015-02-02 21:35:56 -0800</delta_ts>
            <desc>[PATCH] Proposed Fix</desc>
            <filename>initialize.patch</filename>
            <type>text/plain</type>
            <size>1714</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cgYi9Tb3VyY2UvSmF2
YVNjcmlwdENvcmUvQ2hhbmdlTG9nCmluZGV4IDA3Yzk4MzAuLmJmODlmMGMgMTAwNjQ0Ci0tLSBh
L1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKKys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GVJbnNwZWN0b3IubW0K
aW5kZXggZWE0YTg2Zi4uYTM2ZDMyZCAxMDA2NDQKLS0tIGEvU291cmNlL0phdmFTY3JpcHRDb3Jl
L2luc3BlY3Rvci9yZW1vdGUvUmVtb3RlSW5zcGVjdG9yLm1tCisrKyBiL1NvdXJjZS9KYXZhU2Ny
aXB0Q29yZS9pbnNwZWN0b3IvcmVtb3RlL1JlbW90ZUluc3BlY3Rvci5tbQpAQCAtODQsOSArODQs
MTIgQEAgUmVtb3RlSW5zcGVjdG9yJiBSZW1vdGVJbnNwZWN0b3I6OnNpbmdsZXRvbigpCiAgICAg
c3RhdGljIGRpc3BhdGNoX29uY2VfdCBvbmNlOwogICAgIGRpc3BhdGNoX29uY2UoJm9uY2UsIF57
CiAgICAgICAgIGlmIChjYW5BY2Nlc3NXZWJJbnNwZWN0b3JNYWNoUG9ydCgpKSB7Ci0gICAgICAg
ICAgICBKU0M6OmluaXRpYWxpemVUaHJlYWRpbmcoKTsKLSAgICAgICAgICAgIGlmIChSZW1vdGVJ
bnNwZWN0b3I6OnN0YXJ0RW5hYmxlZCkKLSAgICAgICAgICAgICAgICBzaGFyZWQuZ2V0KCkuc3Rh
cnQoKTsKKyAgICAgICAgICAgIGRpc3BhdGNoX2FzeW5jKGRpc3BhdGNoX2dldF9tYWluX3F1ZXVl
KCksIF57CisgICAgICAgICAgICAgICAgV1RGOjppbml0aWFsaXplTWFpblRocmVhZCgpOworICAg
ICAgICAgICAgICAgIEpTQzo6aW5pdGlhbGl6ZVRocmVhZGluZygpOworICAgICAgICAgICAgICAg
IGlmIChSZW1vdGVJbnNwZWN0b3I6OnN0YXJ0RW5hYmxlZCkKKyAgICAgICAgICAgICAgICAgICAg
c2hhcmVkLmdldCgpLnN0YXJ0KCk7CisgICAgICAgICAgICB9KTsKICAgICAgICAgfQogICAgIH0p
OwogCg==
</data>
<flag name="review"
          id="270851"
          type_id="1"
          status="+"
          setter="msaboff"
    />
    <flag name="commit-queue"
          id="270852"
          type_id="3"
          status="-"
          setter="joepeck"
    />
          </attachment>
      

    </bug>

</bugzilla>