Bug 237280 - REGRESSION (r284472): [ Monterey ] http/tests/websocket/tests/hybi/inspector/send-and-recieve-debugger.html is failing
Summary: REGRESSION (r284472): [ Monterey ] http/tests/websocket/tests/hybi/inspector/...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Patrick Angle
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-28 10:46 PST by Truitt Savell
Modified: 2022-03-04 17:07 PST (History)
10 users (show)

See Also:


Attachments
Patch v1.0 - For verification in EWS before review (39.65 KB, patch)
2022-03-02 10:44 PST, Patrick Angle
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch v1.1 - For verification in EWS before review (39.81 KB, patch)
2022-03-02 11:01 PST, Patrick Angle
no flags Details | Formatted Diff | Diff
Patch v1.2 - For verification in EWS before review (33.86 KB, patch)
2022-03-02 14:31 PST, Patrick Angle
no flags Details | Formatted Diff | Diff
Patch v1.3 (34.05 KB, patch)
2022-03-03 09:03 PST, Patrick Angle
no flags Details | Formatted Diff | Diff
Patch v1.4 (34.00 KB, patch)
2022-03-04 09:40 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 Truitt Savell 2022-02-28 10:46:28 PST
http/tests/websocket/tests/hybi/inspector/send-and-recieve-debugger.html

Possibly this test just needs a new baseline for Monterey, seems like there is a minor timing difference. 

History:
https://results.webkit.org/?suite=layout-tests&test=http%2Ftests%2Fwebsocket%2Ftests%2Fhybi%2Finspector%2Fsend-and-recieve-debugger.html

Diff:
--- /Volumes/Data/worker/monterey-release-applesilicon-tests-wk2/build/layout-test-results/http/tests/websocket/tests/hybi/inspector/send-and-recieve-debugger-expected.txt
+++ /Volumes/Data/worker/monterey-release-applesilicon-tests-wk2/build/layout-test-results/http/tests/websocket/tests/hybi/inspector/send-and-recieve-debugger-actual.txt
@@ -9,10 +9,10 @@
 PASS: Frame should be outgoing.
 PASS: Message is walltime.
 Pausing script execution with `debugger` statement.
-Resuming script execution.
 PASS: Resource size should double.
 PASS: Frame data should be 'Hello World! Привет Мир!'
 PASS: Frame should be text.
 PASS: Frame should be incoming.
 PASS: Frame walltime should be greater than the previous one.
+Resuming script execution.
Comment 1 Radar WebKit Bug Importer 2022-02-28 10:48:23 PST
<rdar://problem/89569036>
Comment 2 Alexey Proskuryakov 2022-02-28 15:51:06 PST
This looks like an outright failure, not a timing difference. The purpose of the test is to verify that messages aren't being handled while JS execution is disabled, and that's exactly what is happening here.
Comment 3 Patrick Angle 2022-03-02 10:44:41 PST
Created attachment 453635 [details]
Patch v1.0 - For verification in EWS before review
Comment 4 Patrick Angle 2022-03-02 11:01:52 PST
Created attachment 453638 [details]
Patch v1.1 - For verification in EWS before review
Comment 5 Patrick Angle 2022-03-02 14:31:48 PST
Created attachment 453660 [details]
Patch v1.2 - For verification in EWS before review
Comment 6 Patrick Angle 2022-03-03 09:03:47 PST
Created attachment 453748 [details]
Patch v1.3
Comment 7 Devin Rousso 2022-03-03 11:57:29 PST
Comment on attachment 453748 [details]
Patch v1.3

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

r=me, nice fix! =D

> Source/WebCore/ChangeLog:20
> +        correct this the `WebKit::WebSocketChannel` now provides a hook into its helper `WebInspectorChannelInspector`

Did you mean `WebSocketChannelInspector`?

> Source/WebCore/Modules/websockets/WebSocket.cpp:614
> +        if (auto* inspector = m_channel->channelInspector())

NIT: Should this also be wrapped in a `if (UNLIKELY(InspectorInstrumentation::hasFrontends())) {`?
Comment 8 youenn fablet 2022-03-04 04:43:16 PST
Comment on attachment 453748 [details]
Patch v1.3

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

> Source/WebCore/ChangeLog:19
> +        in the frontend "in the future" (e.g. before the paused script would have been able to be aware of them). To

Isn't it a good thing to have inspector showing what happens in the network, instead of what happens in JS?

> Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:222
> +    m_pendingTasks.append(makeUnique<ScriptExecutionContext::Task>([this, protectedThis = Ref { *this }, reason] (ScriptExecutionContext&) {

didClose is isolating copy reason, which might not be needed.
We should probably be consistent though.

> Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp:330
> +    m_loaderProxy.postTaskForModeToWorkerOrWorkletGlobalScope([workerClientWrapper = m_workerClientWrapper, reason](ScriptExecutionContext& context) mutable {

We need to isolateCopy here since we are hoping to another thread.
Comment 9 Patrick Angle 2022-03-04 08:24:10 PST
Comment on attachment 453748 [details]
Patch v1.3

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

>> Source/WebCore/ChangeLog:19
>> +        in the frontend "in the future" (e.g. before the paused script would have been able to be aware of them). To
> 
> Isn't it a good thing to have inspector showing what happens in the network, instead of what happens in JS?

The web socket is a viewable "source" with a list of events in the Sources Tab of Web Inspector. The behavior before r284472 was that we only showed these messages when they logically happened in relationship to JS.  This is also how Web Socket messages in Web Inspector are still represented pre-Monterey, since the instrumentation isn't called until script execution is resumed and the event loop has its next chance to fire the appropriate events in JS - otherwise the socket may show messages that the author would have wanted to handle, leaving them wondering why their handler was not called as they step through their code since the handler will be informed some time in the future of the message.
Comment 10 Patrick Angle 2022-03-04 09:40:10 PST
Created attachment 453850 [details]
Patch v1.4
Comment 11 Patrick Angle 2022-03-04 16:23:39 PST
Comment on attachment 453850 [details]
Patch v1.4

Oops - meant to set cq+, not r+
Comment 12 EWS 2022-03-04 17:07:52 PST
Committed r290856 (248088@main): <https://commits.webkit.org/248088@main>

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