Skip to content

Commit f0a2678

Browse files
committed
Add diagnostic timeouts to identify which event hangs on Safari
1 parent 98eeaa9 commit f0a2678

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

experimental/tests.mjs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,19 @@ export const ExperimentalSuites = freezeSuites([
194194
const widths = [768, 704, 640, 560, 480];
195195
const MATCH_MEDIA_QUERY_BREAKPOINT = 640;
196196

197-
// The matchMedia query is "(max-width: 640px)"
198-
// Starting from a width > 640px, we'll only get 1 event when crossing to <= 640px
199-
// This happens when the width changes from 704px to 640px
200197
const resizeWorkPromise = new Promise((resolve) => {
201198
page.addEventListener("resize-work-complete", resolve, { once: true });
202199
});
203200

204201
for (const width of widths) {
205202
page.setWidth(width);
206203
page.layout();
207-
if (width === MATCH_MEDIA_QUERY_BREAKPOINT)
208-
await resizeWorkPromise;
204+
if (width === MATCH_MEDIA_QUERY_BREAKPOINT) {
205+
await Promise.race([
206+
resizeWorkPromise,
207+
new Promise((_, reject) => setTimeout(() => reject(new Error("[diag] ReduceWidthIn5Steps: resize-work-complete timed out after 30s")), 30000)),
208+
]);
209+
}
209210
}
210211

211212
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
@@ -249,9 +250,15 @@ export const ExperimentalSuites = freezeSuites([
249250
page.scrollTo(0, page.scrollY + videoRect.top);
250251
page.layout();
251252

252-
await cvWorkComplete;
253+
console.log("[diag] ScrollToChatAndSendMessages: awaiting cvWorkComplete");
254+
await Promise.race([
255+
cvWorkComplete,
256+
new Promise((_, reject) => setTimeout(() => reject(new Error("[diag] ScrollToChatAndSendMessages: video-grid-content-visibility-complete timed out after 30s")), 30000)),
257+
]);
258+
console.log("[diag] ScrollToChatAndSendMessages: done");
253259
}),
254260
new BenchmarkTestStep("IncreaseWidthIn5Steps", async (page) => {
261+
console.log("[diag] IncreaseWidthIn5Steps: start");
255262
const widths = [560, 640, 704, 768, 800];
256263
const MATCH_MEDIA_QUERY_BREAKPOINT = 704;
257264

0 commit comments

Comments
 (0)