Bug 235017

Summary: Web app fails only when dev tools is open
Product: WebKit Reporter: apple-rth
Component: JavaScriptCoreAssignee: Patrick Angle <pangle>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, hi, inspector-bugzilla-changes, joepeck, pangle, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Mac (Intel)   
OS: macOS 11   
URL: https://gsnedders.github.io/webkit-bug-235017/MessagePort.html
Attachments:
Description Flags
Simple web app + screen capture of error
none
Patch v1.0
none
Patch v1.1
none
Patch v1.2 - Correct mistake in comments none

apple-rth
Reported 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.
Attachments
Simple web app + screen capture of error (67.59 KB, application/zip)
2022-01-09 09:26 PST, apple-rth
no flags
Patch v1.0 (2.81 KB, patch)
2022-02-12 11:17 PST, Patrick Angle
no flags
Patch v1.1 (9.70 KB, patch)
2022-02-28 20:18 PST, Patrick Angle
no flags
Patch v1.2 - Correct mistake in comments (9.73 KB, patch)
2022-03-01 11:59 PST, Patrick Angle
no flags
Sam Sneddon [:gsnedders]
Comment 1 2022-01-10 08:02:20 PST
Patrick Angle
Comment 2 2022-02-12 11:17:01 PST
Created attachment 451788 [details] Patch v1.0
Patrick Angle
Comment 3 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.
Patrick Angle
Comment 4 2022-02-28 20:18:39 PST
Created attachment 453469 [details] Patch v1.1
Devin Rousso
Comment 5 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)
Patrick Angle
Comment 6 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!
Patrick Angle
Comment 7 2022-03-01 11:59:17 PST
Created attachment 453517 [details] Patch v1.2 - Correct mistake in comments
EWS
Comment 8 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].
Note You need to log in before you can comment on or make changes to this bug.