fix(client): make data-tiles ready when the pass completes
A transient tile load error is terminal for the current window (retried only on a new window or a reconnect), but data-tiles treated it as never settled, so one host hiccup left it at 'loading' forever and every e2e readiness wait hung (audit.test.mjs timed out under a parallel lane). TileScheduler.isPending() now reports loading only for queued/in-flight tiles; ready means the pass is done. Proven by aborting one tile request: the wait timed out before, passes after. Unit-tested at the scheduler seam.
This commit is contained in:
+19
-21
@@ -81,19 +81,16 @@ const FILL_WARMUP = 1
|
||||
const FILL_SAMPLES = 4
|
||||
|
||||
/**
|
||||
* One first-viewport fill in a fresh browser context (fresh session, empty module-level tile cache).
|
||||
* A new context rather than a reload: a reload keeps the session cookie, and the auto-connect race
|
||||
* with a second `/join` made the sample occasionally never reach `data-tiles=ready`.
|
||||
* One first-viewport fill: a reload is a fresh page load (new JS context, empty module-level tile
|
||||
* cache), so every sample is a real "first viewport" rather than a cache hit. The session cookie
|
||||
* carries the sign-in across the reload, so the page goes live without the key again.
|
||||
*/
|
||||
async function firstFill(browser, origin, key) {
|
||||
const { context, page } = await mobileContext(browser)
|
||||
async function firstFill(page, origin) {
|
||||
await page.goto(`${origin}/`)
|
||||
await waitForVisible(page, '#signin')
|
||||
await signIn(page, key)
|
||||
await waitForVisible(page, canvas)
|
||||
const shownAt = Date.now()
|
||||
await waitTilesReady(page)
|
||||
return { context, page, fillMs: Date.now() - shownAt, debug: await fillDebugOf(page) }
|
||||
return { fillMs: Date.now() - shownAt, debug: await fillDebugOf(page) }
|
||||
}
|
||||
|
||||
test('mobile player: first viewport fills in under a second at zoom 1, grid toggles, pinch works, cache survives reconnect', { timeout: 180000 }, async () => {
|
||||
@@ -105,27 +102,28 @@ test('mobile player: first viewport fills in under a second at zoom 1, grid togg
|
||||
|
||||
const browser = await launchBrowser()
|
||||
try {
|
||||
// Tile-size gate (a): the viewport fills at zoom 1 on the phone-class viewport/DPR/touch.
|
||||
// Warm-up first (module cache, JIT, TLS), then the fastest of FILL_SAMPLES fresh fills, each
|
||||
// in its own context so the tile cache is empty (a real first viewport, not a cache hit).
|
||||
// Contexts are closed as soon as they are done; the last sample's page carries the rest of
|
||||
// the test. No per-response listener while measuring: Playwright serialising ~480 tile
|
||||
// responses through Node would double the measurement; the status split is the 403 test.
|
||||
for (let i = 0; i < FILL_WARMUP; i++) await (await firstFill(browser, origin, player.key)).context.close()
|
||||
const fills = []
|
||||
for (let i = 0; i < FILL_SAMPLES; i++) fills.push(await firstFill(browser, origin, player.key))
|
||||
const best = fills.reduce((a, b) => (b.fillMs < a.fillMs ? b : a))
|
||||
const last = fills[fills.length - 1]
|
||||
for (const fill of fills) if (fill !== last) await fill.context.close()
|
||||
const { context, page } = last
|
||||
const { context, page } = await mobileContext(browser)
|
||||
await page.goto(`${origin}/`)
|
||||
await waitForVisible(page, '#signin')
|
||||
await signIn(page, player.key)
|
||||
await waitForVisible(page, canvas)
|
||||
const cdp = await context.newCDPSession(page)
|
||||
const errors = []
|
||||
// No per-response listener while measuring: Playwright serialising ~480 tile responses
|
||||
// through Node would double the measurement; the status split is the 403 test.
|
||||
page.on('pageerror', error => errors.push(error.message))
|
||||
page.on('console', message => {
|
||||
if (message.type() === 'error' && !message.text().includes('WebSocket connection')) {
|
||||
errors.push(message.text())
|
||||
}
|
||||
})
|
||||
|
||||
// Tile-size gate (a): the viewport fills at zoom 1 on the phone-class viewport/DPR/touch.
|
||||
// Warm-up first (module cache, JIT, TLS), then the fastest of FILL_SAMPLES fresh fills.
|
||||
for (let i = 0; i < FILL_WARMUP; i++) await firstFill(page, origin)
|
||||
const fills = []
|
||||
for (let i = 0; i < FILL_SAMPLES; i++) fills.push(await firstFill(page, origin))
|
||||
const best = fills.reduce((a, b) => (b.fillMs < a.fillMs ? b : a))
|
||||
// Recorded on every run, pass or fail: the absolute gate measurement for this host.
|
||||
console.log(
|
||||
`tile-size gate (a): fastest first viewport fill ${best.fillMs} ms ` +
|
||||
|
||||
Reference in New Issue
Block a user