Bug 253868

Summary: REGRESSION(261559@main) [Win] js/ShadowRealm-iframe-detach.html is randomly timing out
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: WebCore JavaScriptAssignee: Fujii Hironori <Hironori.Fujii>
Status: REOPENED ---    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP patch
none
patch to reproduce the timeout for Mac port none

Description Fujii Hironori 2023-03-13 19:26:54 PDT
REGRESSION(261559@main) [Win] js/ShadowRealm-iframe-detach.html is randomly timing out

After 261559@main (bug#175336) disabled USE_CF for WinCairo, the following tests are randomly timing out.

js/ShadowRealm-iframe-detach.html
js/ShadowRealm-importValue.html

The timeout is more likely happening in the first time. --run-singly switch is useful to reproduce the timeout.
  
> python.exe ./Tools/Scripts/run-webkit-tests --wincairo --debug js/ShadowRealm-iframe-detach.html --iterations=30 -v --no-retry-failures --run-singly

The reproduction rate is 8/30.
Comment 1 Fujii Hironori 2023-03-13 19:28:07 PDT
Created attachment 465428 [details]
WIP patch

This patch resolves the problem. I don't understand reportAbandonedObjectGraph at all.
Comment 2 Fujii Hironori 2023-03-14 19:20:13 PDT
Test gardening by 261667@main.
Comment 3 Fujii Hironori 2023-03-15 19:21:36 PDT
If I keep 'realm' in the 'window' object, the timeout problem doesn't happen. The realm is garbage collected!?

diff --git a/LayoutTests/js/ShadowRealm-iframe-detach.html b/LayoutTests/js/ShadowRealm-iframe-detach.html
index d4651f0897d2..1c0e3721705b 100644
--- a/LayoutTests/js/ShadowRealm-iframe-detach.html
+++ b/LayoutTests/js/ShadowRealm-iframe-detach.html
@@ -22,6 +22,7 @@
  frame.onload = async () => {
      debug(frame);
      let realm = frame.realm;
+     window.xxx = realm;
      debug("detaching iframe");
      document.getElementsByTagName("iframe")[0].remove()
      $vm.gc();
Comment 4 Fujii Hironori 2023-03-16 21:34:33 PDT
Pull request: https://github.com/WebKit/WebKit/pull/11639
Comment 5 Fujii Hironori 2023-03-19 20:51:35 PDT
Created attachment 465511 [details]
patch to reproduce the timeout for Mac port

This timeout is reproducible with Mac port if I apply this patch to take the garbageCollectOnNextRunLoop code path.

> Tools/Scripts/run-webkit-tests --debug js/ShadowRealm-iframe-detach.html --iterations=30 --no-retry-failures --run-singly

The reproduction rate is 25/30.
Comment 6 Radar WebKit Bug Importer 2023-03-20 19:27:25 PDT
<rdar://problem/106974546>
Comment 7 EWS 2023-03-26 21:22:16 PDT
Committed 262136@main (6c72fadf79d3): <https://commits.webkit.org/262136@main>

Reviewed commits have been landed. Closing PR #11639 and removing active labels.
Comment 8 Fujii Hironori 2023-03-28 14:27:45 PDT
The test is still timing out on a Buildbot tester even after 262136@main. Reopened.

https://results.webkit.org/?suite=layout-tests&test=js%2FShadowRealm-importValue.html
Comment 9 Fujii Hironori 2023-03-28 14:34:14 PDT
It's a wrong URL.

js/ShadowRealm-iframe-detach.html is still timing out.
https://results.webkit.org/?platform=wincairo&suite=layout-tests&test=js%2FShadowRealm-iframe-detach.html

js/ShadowRealm-importValue.html and http/tests/misc/iframe-shadow-realm.html doesn't seem to time out after the change.
https://results.webkit.org/?platform=wincairo&suite=layout-tests&suite=layout-tests&test=js%2FShadowRealm-importValue.html&test=http%2Ftests%2Fmisc%2Fiframe-shadow-realm.html