Bug 235017 - Web app fails only when dev tools is open
Summary: Web app fails only when dev tools is open
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari Technology Preview
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Patrick Angle
URL: https://gsnedders.github.io/webkit-bu...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-01-09 09:26 PST by apple-rth
Modified: 2022-03-01 13:20 PST (History)
6 users (show)

See Also:


Attachments
Simple web app + screen capture of error (67.59 KB, application/zip)
2022-01-09 09:26 PST, apple-rth
no flags Details
Patch v1.0 (2.81 KB, patch)
2022-02-12 11:17 PST, Patrick Angle
no flags Details | Formatted Diff | Diff
Patch v1.1 (9.70 KB, patch)
2022-02-28 20:18 PST, Patrick Angle
no flags Details | Formatted Diff | Diff
Patch v1.2 - Correct mistake in comments (9.73 KB, patch)
2022-03-01 11:59 PST, Patrick Angle
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description apple-rth 2022-01-09 09:26:26 PST
Created attachment 448705 [details]
Simple web app + screen capture of error

The attached simple web app works when developer tools is closed but fails when developer tools is open, showing "This webpage was reloaded because a problem occurred." (see screencap in attached archive).

The web app displays no user interface. It creates two workers and sends messages for 10 seconds between the page and workers using both Worker and MessagePort postMessage. The workers log status to the console.

If you open MessagePort.html with dev tools *closed*, wait ten seconds, and then open the console, the console should show this expected output (random worker ids will differ on each load):

[Log] worker – "0.8ea61cc652bf18" (MessagePort.js, line 3)
[Log] 0.8ea61cc652bf18 – "received port" (MessagePort.js, line 7)
[Log] 0.8ea61cc652bf18 – "received message" – "1" (MessagePort.js, line 13)
[Log] 0.8ea61cc652bf18 – "received port" (MessagePort.js, line 7)
[Log] 0.8ea61cc652bf18 – "received message" – "3" (MessagePort.js, line 13)
[Log] 0.8ea61cc652bf18 – "received port" (MessagePort.js, line 7)
[Log] 0.8ea61cc652bf18 – "received message" – "5" (MessagePort.js, line 13)
[Log] 0.8ea61cc652bf18 – "received port" (MessagePort.js, line 7)
[Log] 0.8ea61cc652bf18 – "received message" – "7" (MessagePort.js, line 13)
[Log] 0.8ea61cc652bf18 – "received port" (MessagePort.js, line 7)
[Log] 0.8ea61cc652bf18 – "received message" – "9" (MessagePort.js, line 13)
[Log] worker – "0.5ccb01cc4dd668" (MessagePort.js, line 3)
[Log] 0.5ccb01cc4dd668 – "received port" (MessagePort.js, line 7)
[Log] 0.5ccb01cc4dd668 – "received message" – "0" (MessagePort.js, line 13)
[Log] 0.5ccb01cc4dd668 – "received port" (MessagePort.js, line 7)
[Log] 0.5ccb01cc4dd668 – "received message" – "2" (MessagePort.js, line 13)
[Log] 0.5ccb01cc4dd668 – "received port" (MessagePort.js, line 7)
[Log] 0.5ccb01cc4dd668 – "received message" – "4" (MessagePort.js, line 13)
[Log] 0.5ccb01cc4dd668 – "received port" (MessagePort.js, line 7)
[Log] 0.5ccb01cc4dd668 – "received message" – "6" (MessagePort.js, line 13)
[Log] 0.5ccb01cc4dd668 – "received port" (MessagePort.js, line 7)
[Log] 0.5ccb01cc4dd668 – "received message" – "8" (MessagePort.js, line 13)
[Log] 0.5ccb01cc4dd668 – "received port" (MessagePort.js, line 7)

If you load the page when dev tools is *open*, you will only see:

[Log] worker – "0.b17e186a48b3d" (MessagePort.js, line 3)
[Log] worker – "0.701a3cedb2def8" (MessagePort.js, line 3)
[Log] 0.701a3cedb2def8 – "received port" (MessagePort.js, line 7)
[Log] 0.701a3cedb2def8 – "received message" – "0" (MessagePort.js, line 13)
[Log] 0.b17e186a48b3d – "received port" (MessagePort.js, line 7)

with no error displayed in dev tools, only the "This webpage was reloaded because a problem occurred." notice on the page itself.

I see this both on production Safari (Version 15.2 (16612.3.6.1.8, 16612)) and Technology Preview 137 on macOS 11.6.2. It works properly on Chrome 96 and Firefox 95.


This test page transfers a MessagePort back and forth between the workers (via the main page). It is possible that the failure when dev tools is open has something to do with that.
Comment 1 Sam Sneddon [:gsnedders] 2022-01-10 08:02:20 PST
<rdar://87340464>
Comment 2 Patrick Angle 2022-02-12 11:17:01 PST
Created attachment 451788 [details]
Patch v1.0
Comment 3 Patrick Angle 2022-02-12 11:18:11 PST
Comment on attachment 451788 [details]
Patch v1.0

No tests currently as I'm unable to get the issue to reproduce under the test harness, even with an essentially identical test to the reproduction case provided by the originator.
Comment 4 Patrick Angle 2022-02-28 20:18:39 PST
Created attachment 453469 [details]
Patch v1.1
Comment 5 Devin Rousso 2022-03-01 11:37:57 PST
Comment on attachment 453469 [details]
Patch v1.1

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

r=me

> Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp:223
> +    // `event.target()->injectedScript()` can change between `willHandleEvent` and `didHandleEvent`. The

NIT: I think you meant `scriptExecutionContext()`? 😅

> Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp:267
> +    // `event.target()->injectedScript()` can change between `willHandleEvent` and `didHandleEvent`. Here it could also

ditto (:223)
Comment 6 Patrick Angle 2022-03-01 11:41:46 PST
Comment on attachment 453469 [details]
Patch v1.1

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

>> Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp:223
>> +    // `event.target()->injectedScript()` can change between `willHandleEvent` and `didHandleEvent`. The
> 
> NIT: I think you meant `scriptExecutionContext()`? 😅

Good catch!
Comment 7 Patrick Angle 2022-03-01 11:59:17 PST
Created attachment 453517 [details]
Patch v1.2 - Correct mistake in comments
Comment 8 EWS 2022-03-01 13:20:31 PST
Committed r290671 (247942@main): <https://commits.webkit.org/247942@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453517 [details].