<?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>157240</bug_id>
          
          <creation_ts>2016-04-30 18:00:52 -0700</creation_ts>
          <short_desc>Web Inspector: Can&apos;t resume Debugger after breaking on exception in Promise</short_desc>
          <delta_ts>2016-05-19 23:31:05 -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>Web Inspector</component>
          <version>WebKit 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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Timothy Hatcher">timothy</reporter>
          <assigned_to name="Joseph Pecoraro">joepeck</assigned_to>
          <cc>bburg</cc>
    
    <cc>commit-queue</cc>
    
    <cc>graouts</cc>
    
    <cc>joepeck</cc>
    
    <cc>mark.lam</cc>
    
    <cc>mattbaker</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>1189148</commentid>
    <comment_count>0</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2016-04-30 18:00:52 -0700</bug_when>
    <thetext>Steps:
1) Enable break on All Exceptions
2) Run this code in the console from bug 156114:

    crypto.webkitSubtle.generateKey({
        name: &quot;RSA-OAEP&quot;,
        modulusLength: 2048,
        publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
        hash: {name: &quot;SHA-256&quot;}
    }, true, [&quot;encrypt&quot;, &quot;decrypt&quot; ]).then((keypair) =&gt; {
        console.log(&quot;Generated Key Pair:&quot;, keypair);
        return crypto.webkitSubtle.exportKey(&quot;jwk&quot;, keypair.publicKey);
    }).then((keydata) =&gt; {
        console.log(&quot;Key Data:&quot;, keydata);
    }).catch((error) =&gt; {
        console.log(&quot;Error: &quot;, error);
    });

3) It should stop on the return line with an exception
4) Try to continue
5) console.log should be logged with the error from the Promise catch
6) Still appear paused, try to continue

Results: Appears to stay paused, but it does resume. Error is logged when inspecting Inspector:

[Error] DebuggerManager.resume failed: – Error: Can only perform operation while paused.
    Error: Can only perform operation while paused.
        _dispatchResponseToPromise — InspectorBackend.js:307
        _dispatchResponse — InspectorBackend.js:272
        dispatch — InspectorBackend.js:149
        dispatchNextQueuedMessageFromBackend — MessageDispatcher.js:42

(anonymous function) (DebuggerManager.js:194)
promiseReactionJob</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1189149</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2016-04-30 18:01:47 -0700</bug_when>
    <thetext>&lt;rdar://problem/26030890&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1189150</commentid>
    <comment_count>2</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2016-04-30 18:06:35 -0700</bug_when>
    <thetext>You might also need to click continue a couple times to get the console.log to appear. Then further continues will log the error in the Inspector.

We need to make sure the debugger UI never gets out of sync with the backend, which is what appears to be happening here. You can use the Inspector when it is in this state, but a developer will think the page is still pauses and will be confused.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1194107</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2016-05-17 19:09:22 -0700</bug_when>
    <thetext>The issue is due to the DebuggerManager not resuming the backend when it resumed the front end:

In the test case, a Promise throws an exception on rejection.  Since this is in builtin code, the DebuggerManager detects that there are no active frames on the stack, and chooses to resume the front-end.  Unfortunately, it did not resume the back end as well.  As a result, the backend sits in its event loop perpetually.

A patch with the fix is coming shortly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1194397</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2016-05-18 13:10:56 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; The issue is due to the DebuggerManager not resuming the backend when it
&gt; resumed the front end:
&gt; 
&gt; In the test case, a Promise throws an exception on rejection.  Since this is
&gt; in builtin code, the DebuggerManager detects that there are no active frames
&gt; on the stack, and chooses to resume the front-end.  Unfortunately, it did
&gt; not resume the back end as well.  As a result, the backend sits in its event
&gt; loop perpetually.
&gt; 
&gt; A patch with the fix is coming shortly.

Correction: there&apos;s more to this than what we thought above.  With the explicit call to the resume the backend, the backend does get resumed.  However, the front end still looks like it is stopped on a breakpoint.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1194400</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2016-05-18 13:32:10 -0700</bug_when>
    <thetext>Joe suggested, for a test, that I change the bail check at the top of DebuggerManager&apos;s _didResumeInternal() to &quot;if (!this._paused) return&quot;.  With that plus the explicit call to DebuggerAgent.resume() added to debuggerDidPause(), the issue appears to be resolved.

That said, I&apos;m not sure that this is the proper fix though. Sending this bug over to Joe since the bug appears to be at the Inspector level.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1195091</commentid>
    <comment_count>6</comment_count>
      <attachid>279467</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2016-05-19 22:12:40 -0700</bug_when>
    <thetext>Created attachment 279467
[PATCH] Proposed Fix</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1195102</commentid>
    <comment_count>7</comment_count>
      <attachid>279467</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-05-19 23:31:00 -0700</bug_when>
    <thetext>Comment on attachment 279467
[PATCH] Proposed Fix

Clearing flags on attachment: 279467

Committed r201211: &lt;http://trac.webkit.org/changeset/201211&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1195103</commentid>
    <comment_count>8</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-05-19 23:31:05 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>279467</attachid>
            <date>2016-05-19 22:12:40 -0700</date>
            <delta_ts>2016-05-19 23:31:00 -0700</delta_ts>
            <desc>[PATCH] Proposed Fix</desc>
            <filename>pause-fix.patch</filename>
            <type>text/plain</type>
            <size>2814</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJJbnNwZWN0b3JVSS9DaGFuZ2VMb2cgYi9Tb3VyY2UvV2Vi
SW5zcGVjdG9yVUkvQ2hhbmdlTG9nCmluZGV4IDVkZjMwM2UuLmIxZDg3NTcgMTAwNjQ0Ci0tLSBh
L1NvdXJjZS9XZWJJbnNwZWN0b3JVSS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYkluc3BlY3Rv
clVJL0NoYW5nZUxvZwpAQCAtMSwzICsxLDI5IEBACisyMDE2LTA1LTE5ICBKb3NlcGggUGVjb3Jh
cm8gIDxwZWNvcmFyb0BhcHBsZS5jb20+CisKKyAgICAgICAgV2ViIEluc3BlY3RvcjogQ2FuJ3Qg
cmVzdW1lIERlYnVnZ2VyIGFmdGVyIGJyZWFraW5nIG9uIGV4Y2VwdGlvbiBpbiBQcm9taXNlCisg
ICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xNTcyNDAKKyAg
ICAgICAgPHJkYXI6Ly9wcm9ibG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mplY3QKICAgICAgICAgdGhpcy5fYWN0aXZlQ2FsbEZyYW1lID0gdGhp
cy5fY2FsbEZyYW1lc1swXTsKIAogICAgICAgICBpZiAoIXRoaXMuX2FjdGl2ZUNhbGxGcmFtZSkg
ewotICAgICAgICAgICAgY29uc29sZS53YXJuKCJXZSBzaG91bGQgYWx3YXlzIGhhdmUgb25lIGNh
bGwgZnJhbWUuIFRoaXMgY291bGQgaW5kaWNhdGUgd2UgYXJlIGhpdHRpbmcgYW4gZXhjZXB0aW9u
IG9yIGRlYnVnZ2VyIHN0YXRlbWVudCBpbiBhbiBpbnRlcm5hbCBpbmplY3RlZCBzY3JpcHQuIik7
CisgICAgICAgICAgICAvLyBUaGlzIGluZGljYXRlcyB3ZSB3ZXJlIHBhdXNpbmcgaW4gaW50ZXJu
YWwgc2NyaXB0cyBvbmx5IChJbmplY3RlZCBTY3JpcHRzLCBidWlsdC1pbnMpLgorICAgICAgICAg
ICAgLy8gSnVzdCByZXN1bWUgYW5kIHNraXAgcGFzdCB0aGlzIHBhdXNlLgorICAgICAgICAgICAg
RGVidWdnZXJBZ2VudC5yZXN1bWUoKTsKICAgICAgICAgICAgIHRoaXMuX2RpZFJlc3VtZUludGVy
bmFsKCk7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KQEAgLTkxNiw3ICs5MTgsNyBA
QCBXZWJJbnNwZWN0b3IuRGVidWdnZXJNYW5hZ2VyID0gY2xhc3MgRGVidWdnZXJNYW5hZ2VyIGV4
dGVuZHMgV2ViSW5zcGVjdG9yLk9iamVjdAogCiAgICAgX2RpZFJlc3VtZUludGVybmFsKCkKICAg
ICB7Ci0gICAgICAgIGlmICghdGhpcy5fYWN0aXZlQ2FsbEZyYW1lKQorICAgICAgICBpZiAoIXRo
aXMuX3BhdXNlZCkKICAgICAgICAgICAgIHJldHVybjsKIAogICAgICAgICBpZiAodGhpcy5fZGVs
YXllZFJlc3VtZVRpbWVvdXQpIHsK
</data>

          </attachment>
      

    </bug>

</bugzilla>