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.
<rdar://87340464>
Created attachment 451788 [details] Patch v1.0
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.
Created attachment 453469 [details] Patch v1.1
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 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!
Created attachment 453517 [details] Patch v1.2 - Correct mistake in comments
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].