diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 986815447..c9c61f993 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -8508,10 +8508,8 @@ function skelSeen() { // left, and with the bird turned off neither runs (a 1-core server: // Yayoi_no_yume on X). let skelSince = 0, skelFlying = false, skelTick = 0; -// Once the bird has come it lands at least once (the owner, 10-30: a load -// done as it came had it streak off over no skeleton): a read back before -// then waits for it, and is let go as it leaves. At most 1.5s, for a frame -// a hidden window never draws. +// Once come, the bird lands three times (~1.6s) before a read goes in (the +// owner, 10-30). At most 3s: a hidden window draws no frames. let skelGate = null, skelWaiting = 0; async function skelHold() { if (!skelGate) return; @@ -8542,7 +8540,7 @@ async function skelBird() { skelFlying = true; let release; const gate = skelGate = new Promise((ok) => { release = () => { if (skelGate === gate) skelGate = null; ok(); }; }); - setTimeout(release, 1500); + setTimeout(release, 3000); const b = el("div", "sk-bird roam"); b.innerHTML = BIRD; document.body.append(b); @@ -8570,17 +8568,20 @@ async function skelBird() { put({ x: at.x - 24, y: at.y - 40, f: 1 }); b.animate([{ opacity: 0 }, { opacity: 1 }], 120); await tween(300, (e, t) => put({ x: at.x - 24 + 24 * t, y: at.y - 40 + 40 * e, sx: 1 - .05 * t, sy: 1 + .08 * t }), easeIn); - // its bar gone before it landed: it fades where it is, never flying - // over what came instead + // its bar gone mid-drop: it fades, never flying over the content if (!s.isConnected) return void (quiet = true); for (let hops = 0; hops < 400; hops++) { // it lands: the bar dips under it and springs back s.animate([{ transform: "none" }, { transform: "translateY(3px)", offset: .3 }, { transform: "translateY(-1.2px)", offset: .6 }, { transform: "translateY(.4px)", offset: .8 }, { transform: "none" }], { duration: 560, easing: "ease-out" }); await tween(130, (e) => put({ y: at.y + 3 * e, sx: 1 + .14 * e, sy: 1 - .18 * e }), easeOut); await tween(90, (e) => put({ y: at.y + 3 * (1 - e), sx: 1.14 - .14 * e, sy: .82 + .18 * e }), easeIn); - // landed once: a read held for it means the load is done - if (!hops && skelWaiting) break; - if (!hops) release(); + // third landing: held reads go in; it stands while the page fills, + // and leaves only when no bar is left + if (hops === 2) { + const held = skelWaiting; + release(); + if (held) await new Promise((ok) => setTimeout(ok, 160)); + } const to = birdOff() ? null : next(s); if (!to) break; const from = { x, y }, go = spot(to), h = 16 + Math.min(40, Math.hypot(go.x - from.x, go.y - from.y) * .15); diff --git a/internal/gui/tests/skeleton-bird.test.cjs b/internal/gui/tests/skeleton-bird.test.cjs index a97d630ca..7ffbd81e8 100644 --- a/internal/gui/tests/skeleton-bird.test.cjs +++ b/internal/gui/tests/skeleton-bird.test.cjs @@ -3,7 +3,8 @@ // still up after a moment, as on a slow page, get the bird, which hops from // bar to bar, each bar dipping under it, and flies off once they are gone. // A quick load never sees it, and with reduced motion no bird comes. Once -// it has come it lands once before the page fills (the owner, 10-30). +// it has come it lands three times before the page fills (the owner, +// 10-30), and a read of something else never sends it off early. // Settings' Loading bird (Yayoi_no_yume on X, a 1-core server) turns it // off: no bird comes and nothing looks for skeletons. With it on, the look // every 250ms runs only while a skeleton is in the page. @@ -99,7 +100,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.deepEqual(errors, []); }); - test(engine + ": a load done as the bird comes keeps its skeletons until the bird has landed once", async (t) => { + test(engine + ": a load done as the bird comes keeps its skeletons until the bird has landed three times", async (t) => { const browser = await launch(); t.after(() => browser.close()); let release; @@ -117,11 +118,35 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.waitForFunction(() => seen.goneAt, null, { timeout: 3000 }); const { dipsAtGone, goneAt } = await page.evaluate(() => seen); assert.ok(dipsAtGone > 0, "the bird landed on a bar before the skeletons went"); - assert.ok(goneAt - at < 1500, `the load waited at most for one landing (${Math.round(goneAt - at)}ms)`); + // drop 300ms, three landings 220ms each, two hops 340ms each: ~1.64s + assert.ok(goneAt - at > 1300, `the load waited for three landings (${Math.round(goneAt - at)}ms)`); + assert.ok(goneAt - at < 3500, `and no longer (${Math.round(goneAt - at)}ms)`); await page.waitForFunction(() => !document.querySelector(".sk-bird"), null, { timeout: 2000 }); assert.deepEqual(errors, []); }); + test(engine + ": a read of something else, as the bird lands, doesn't send it off while skeletons are up", async (t) => { + const browser = await launch(); + t.after(() => browser.close()); + let release; + const held = new Promise((r) => { release = r; }); + const { page, errors } = await open(browser, false, () => held); + await page.locator("#view-plugins .pm-card.ghost").first().waitFor(); + await page.locator(".sk-bird.roam").waitFor({ state: "attached", timeout: 3000 }); + // reads the page makes as the bird drops and lands, none of them the + // one the skeletons wait for + await page.evaluate(() => { for (const ms of [0, 100, 250, 400]) setTimeout(() => api("/api/state"), ms); }); + await page.waitForTimeout(2500); + assert.equal(await page.evaluate(() => seen.birds), 1, "one bird, still on the skeletons"); + assert.ok(await page.locator(".sk-bird.roam").count(), "it is still there"); + assert.ok(await page.evaluate(() => seen.places.size > 30 && seen.dips > 0), "it hops bar to bar"); + release(); + await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-card.ghost")); + await page.waitForFunction(() => !document.querySelector(".sk-bird"), null, { timeout: 2000 }); + assert.equal(await page.evaluate(() => seen.birds), 1); + assert.deepEqual(errors, []); + }); + test(engine + ": a quick load never sees the bird", async (t) => { const browser = await launch(); t.after(() => browser.close());