feedback1 integrate: form fx survive the render engine's stale-event drop; hidden-tab backlog compacted and flushed when a finished battle is shown; same-field re-entry buffered
- render/interp.js isCosmeticEvent: an fx with a form is state, never dropped as stale nor shed from a full queue; a late one switches the model without its telegraph, its closing clip shortened (render/app.js) - battle/runner.js: a backlog past HELD_MAX keeps only the last status / skill toggle per unit; a battle that ended while the tab was hidden delivers its backlog and last snapshot when the tab is shown - screens/game.js: a new field meta for the field on screen buffers its frames until the view re-enters it - browser test stalls the main thread (blocking 1 s long tasks); Node tests drive the runner into the render buffer
This commit is contained in:
1 parent
88d419b095
commit
4e68100065
11 files changed
+259
-39
No files matched your search
@@ -9,8 +9,10 @@
|
||||
// field watched later, 联防 observers or a reconnect — starts in the current forms (UnitInfo `form` → render/app.js
|
||||
// renderInfo): it used to draw the warrior / the A model again (the look of report #5) and 掠海漂移体 hovering;
|
||||
// the real client runner (battle/runner.js createBattleRunner) feeding the view the way screens/game.js does, with
|
||||
// janky 0.7 s frames (every frame a catch-up) across the change of a 转译基底·α that walks into 百炼嘉维尔's block:
|
||||
// the view turns 幽灵 (C_*) — the catch-up filter used to drop the form fx, so it stayed on A_Move and died on B_Die.
|
||||
// blocking 1 s long tasks (every frame a catch-up, and the render clock jumps past its 1.5 game s stale-event
|
||||
// window) across the change of a 转译基底·α that walks into 百炼嘉维尔's block: the view turns 幽灵 (C_*) — the
|
||||
// catch-up filter, and then render/interp.js's stale-event drop, used to lose the form fx, so it stayed on A_Move
|
||||
// and died on B_Die.
|
||||
//
|
||||
// Opt-in (starts Chrome): RENDER_E2E=1 node --test test/render/feedback1-forms.browser.test.js
|
||||
// Chrome path: $CHROME_PATH or the macOS default. Screenshots → test/e2e/out/feedback1-*.png.
|
||||
@@ -126,8 +128,8 @@ async function lateViewInPage(page, port, s, atSecs, setupSrc) {
|
||||
|
||||
/**
|
||||
* The real client runner in the page (fake socket / store, its default sim loader and clock) feeds the demo's view like
|
||||
* screens/game.js (field → enterBattle, snap → pushSnapshot, ev → pushEvents); its animation frames come every `jankMs`
|
||||
* real ms for `secs` real s. Returns samples { t, simForm, form, clip, spine, alive } of the 转译基底·α's view and the
|
||||
* screens/game.js (field → enterBattle, snap → pushSnapshot, ev → pushEvents); every frame follows a blocking `jankMs`
|
||||
* real ms long task, for `secs` real s. Returns samples { t, simForm, form, clip, spine, alive } of the 转译基底·α's view and the
|
||||
* runner's catch-up count.
|
||||
*/
|
||||
async function runnerInPage(page, port, s, jankMs, secs) {
|
||||
@@ -155,7 +157,11 @@ async function runnerInPage(page, port, s, jankMs, secs) {
|
||||
const out = [];
|
||||
const end = performance.now() + secs * 1000;
|
||||
while (performance.now() < end) {
|
||||
await sleep(jankMs);
|
||||
// a blocking long task (the main thread stalls: the render engine's own ticker stalls too, so its clock jumps
|
||||
// jankMs × 2 game s at once — past the 1.5 game s stale-event window), then one free frame
|
||||
const until = performance.now() + jankMs;
|
||||
while (performance.now() < until) { /* stall */ }
|
||||
await sleep(16);
|
||||
for (const fn of queue.splice(0)) fn(performance.now());
|
||||
const tr = e.battle.units.find((u) => u.defId === 'enemy_10081_mpplai');
|
||||
const view = tr && v.debug.views.get(tr.id);
|
||||
@@ -271,10 +277,10 @@ describe('player reports after 0.1.0: the models follow the knock-out forms (hea
|
||||
await p.close();
|
||||
}
|
||||
});
|
||||
test('the real client runner with janky frames (every frame a catch-up): 转译基底·α blocked by 百炼嘉维尔 turns 幽灵 in the view (C_*), never back to A_Move / B_Die', async () => {
|
||||
test('the real client runner with blocking 1 s long tasks (every frame a catch-up, the render clock jumps 2 game s): 转译基底·α blocked by 百炼嘉维尔 turns 幽灵 in the view (C_*), never back to A_Move / B_Die', async () => {
|
||||
const { p, problems } = await page();
|
||||
try {
|
||||
const { out, catchups } = await runnerInPage(p, srv.port, spec('enemy_10081_mpplai', 'runner', 9, 7), 700, 9);
|
||||
const { out, catchups } = await runnerInPage(p, srv.port, spec('enemy_10081_mpplai', 'runner', 9, 7), 1000, 12);
|
||||
await p.screenshot({ path: path.join(OUT, 'feedback1-runner.png') });
|
||||
assert.ok(catchups >= 5, `catch-up frames (${catchups})`);
|
||||
const changed = out.find((x) => x.simForm === 'translator_youling');
|
||||
|
||||
@@ -369,5 +369,10 @@ test('render/app.js renderInfo keeps UnitInfo `form` (it used to drop it: views
|
||||
|
||||
test('render/app.js hands the `form` of a sim fx (shared/protocol.js fxForm) with the fx to the view and keeps the mode on the unit info', () => {
|
||||
const src = readFileSync(path.join(ROOT, 'public/js/render/app.js'), 'utf8');
|
||||
assert.match(src, /const form = fxForm\(e\);[\s\S]{0,200}inf\.form = form[\s\S]{0,120}setForm\?\.\(form, e\[4\]\)/);
|
||||
assert.match(src, /const form = fxForm\(e\);[\s\S]{0,250}inf\.form = form[\s\S]{0,250}setForm\?\.\(form, x\)/);
|
||||
// a form fx handed out late (render/interp.js takeEvents `late`) switches the model with its closing clip shortened by
|
||||
// the lateness and without replaying its telegraph
|
||||
assert.match(src, /const x = late > 0 && Number\(e\[4\]\.dur\) > 0 \? \{ \.\.\.e\[4\], dur: Math\.max\(0, Number\(e\[4\]\.dur\) - late\) \} : e\[4\];/);
|
||||
assert.match(src, /if \(!\(late > 0\)\) fx\.simFx\(/);
|
||||
assert.match(src, /interp\.takeEvents\(renderT, EVS, renderT - 1\.5, LATE\);/);
|
||||
});
|
||||
@@ -5,6 +5,7 @@ import { test, describe } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { SnapshotBuffer, normalizeSnapshot, isCosmeticEvent, frameTime } from '../../public/js/render/interp.js';
|
||||
|
||||
const fxFormOf = (e) => (e && e[0] === 'fx' && e[4] && Object.hasOwn(e[4], 'form') ? e[4].form : undefined);
|
||||
const near = (a, b, eps = 1e-6) => Math.abs(a - b) <= eps;
|
||||
const snap = (t, units) => ({ fieldId: 'n:1', t, units, dp: 10, killed: 0, total: 5 });
|
||||
const U = (id, x, y, hp = 100, anim = 0, flags = 0) => [id, x, y, hp, 100, 5, 10, flags, anim];
|
||||
@@ -188,6 +189,30 @@ describe('SnapshotBuffer', () => {
|
||||
assert.deepEqual(b.flushEvents().map((e) => e[0]), ['leak']);
|
||||
});
|
||||
|
||||
test('an enemy\'s form fx is state (player report #5 after 0.1.0): it survives the stale drop and the full-queue shed, a plain fx does not', () => {
|
||||
const form = (id, f) => ['fx', 'phase', 1, 1, { id, kind: f, form: f, dur: 2 }];
|
||||
assert.ok(!isCosmeticEvent(form(3, 'translator_youling')), 'a form fx is never cosmetic');
|
||||
assert.ok(!isCosmeticEvent(['fx', 'revive', 1, 1, { id: 3, form: null }]), 'back to the base clips (form null) too');
|
||||
assert.ok(isCosmeticEvent(['fx', 'phase', 1, 1, { id: 3, kind: 'artsBarrier' }]), 'a barrier phase stays cosmetic');
|
||||
// a 1 s stall at 2×: the render clock jumps past the 1.5 game s window
|
||||
const b = new SnapshotBuffer();
|
||||
b.pushEvents([['dmg', 3, 5, 'phys'], form(3, 'translator_youling'), ['fx', 'burst', 1, 1, {}]], 0, 1);
|
||||
const late = new Map();
|
||||
const out = b.takeEvents(10, [], 10 - 1.5, late);
|
||||
assert.deepEqual(out.map((e) => e[4]?.form ?? e[0]), ['translator_youling'], 'only the form fx is handed out');
|
||||
assert.ok(Math.abs(late.get(out[0]) - 9) < 1e-9, 'with its lateness (game s)');
|
||||
// replayed without a stamp right after a reset (screens/game.js early buffer: stamped 0)
|
||||
const r = new SnapshotBuffer();
|
||||
r.pushEvents([form(4, 'husk'), ['fx', 'ember', 1, 1, { r: 1 }]], 0);
|
||||
assert.deepEqual(r.takeEvents(30, [], 28.5).map(fxFormOf), ['husk']);
|
||||
// a hidden-tab flood: the shed keeps it
|
||||
const q = new SnapshotBuffer();
|
||||
q.pushEvents([form(5, 'reborn')], 0, 0.5);
|
||||
for (let i = 0; i < 70; i++) q.pushEvents(Array.from({ length: 100 }, () => ['fx', 'burst', 1, 1, {}]), 0, 1 + i * 0.01);
|
||||
assert.ok(q.events.length <= 6000, `bounded (${q.events.length})`);
|
||||
assert.equal(q.events.filter((e) => e.ev[4]?.form === 'reborn').length, 1, 'never shed');
|
||||
});
|
||||
|
||||
test('sample before any snapshot / with NaN time is empty; update before snapshots is NaN', () => {
|
||||
const b = new SnapshotBuffer();
|
||||
assert.ok(Number.isNaN(b.update(1)));
|
||||
|
||||
Reference in new issue
Block a user