feat(m4): cap map images at Full HD and shrink on import (#85)
The owner fixed the map cap at 1920 px on the long side and 1080 px on the short side (either orientation). fff-vtt import now shrinks a larger source with ImageMagick Lanczos before tiling (alpha kept, proportions preserved, no upscaling), prints `scaled WxH -> WxH`, and records the shrunk w/h; a source at or below the cap is untouched, so the pixel-identity tests still hold. A scene row already above the cap is not rewritten: the server logs `map_above_cap` at startup and serve prints the re-import advice. Docs: ADR-0023, DESIGN 3.3/5.3/8/11.1/13/14, TESTING 5.3/13, README, HANDOFF-M4, client README. The M4 phone gate and the fogbench measurement now use the Full HD maximum; the 16384 px / 262144-cell bench and test rows stay as labelled server stress references. import-scale now proves a 16384² input is shrunk to 1080x1080 (289 tiles at 64 px) quickly and bounded. Part of #63, #85. #77 is blocked by this issue.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// T13 (#76): the 50-token, 16384 px map measurement the finish ticket records in
|
||||
// T13 (#76): the 50-token, Full HD map measurement the finish ticket records in
|
||||
// `results/m4-fog-bench.md`. This is NOT the phone gate: headless Chromium here renders with
|
||||
// SwiftShader (software), so its frame cadence is a floor for correctness work, never a substitute
|
||||
// for the Note 10 run (#77). The server half of the same measurement is `tools/fogbench.nim`.
|
||||
//
|
||||
// The scene is the real one, patched to 16384 px (only the importer owns w/h, so the harness writes
|
||||
// the scene row before the server loads it). 50 tokens sit inside the player's sight; the fog
|
||||
// texture is therefore 512x512 cells, the real M4 maximum.
|
||||
// The scene is the real one, patched to the Full HD cap (1920x1080; only the importer owns w/h, so
|
||||
// the harness writes the scene row before the server loads it). 50 tokens sit inside the player's
|
||||
// sight; the fog texture is therefore 60x34 cells, the real M4 maximum (#85).
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { spawnSync } from 'node:child_process'
|
||||
@@ -16,13 +16,13 @@ import { writeTileGrid } from '../../tools/tilefixture.mjs'
|
||||
import { launchBrowser, signIn, waitForVisible, withStack, sleep } from './stack.mjs'
|
||||
|
||||
const MOBILE = { viewport: { width: 412, height: 869 }, deviceScaleFactor: 2.625, isMobile: true, hasTouch: true }
|
||||
const SIZE = 16384
|
||||
const CENTRE = [SIZE / 2, SIZE / 2]
|
||||
const SIZE = { w: 1920, h: 1080 }
|
||||
const CENTRE = [SIZE.w / 2, SIZE.h / 2]
|
||||
|
||||
/** The scene row is the importer's (DESIGN 6.1: w/h are not wire fields); write it before boot. */
|
||||
function setSceneSize(stateDir, size) {
|
||||
const db = path.join(stateDir, 'state.db')
|
||||
const r = spawnSync('sqlite3', [db, `UPDATE scene SET w=${size}, h=${size} WHERE id=1`], { encoding: 'utf8' })
|
||||
const r = spawnSync('sqlite3', [db, `UPDATE scene SET w=${size.w}, h=${size.h} WHERE id=1`], { encoding: 'utf8' })
|
||||
assert.equal(r.status, 0, `set scene size: ${r.stderr}`)
|
||||
}
|
||||
|
||||
@@ -89,19 +89,22 @@ const fogState = page =>
|
||||
}
|
||||
})
|
||||
|
||||
test('50-token fog measurement on a 16384 px map (headless SwiftShader, not the phone gate)', { timeout: 180000 }, async () => {
|
||||
test('50-token fog measurement on a Full HD map (headless SwiftShader, not the phone gate)', { timeout: 180000 }, async () => {
|
||||
await withStack(async ({ origin, gmKey, stateDir }) => {
|
||||
const gm = await gmWorld(origin, gmKey)
|
||||
const scene = gm.scene
|
||||
assert.equal(scene.w, SIZE, 'the prepared scene is 16384 px')
|
||||
assert.equal(scene.w, SIZE.w, 'the prepared scene is 1920 px wide')
|
||||
assert.equal(scene.h, SIZE.h, 'the prepared scene is 1080 px high')
|
||||
const player = await createPlayer(gm.ws)
|
||||
await namePlayer(origin, player.key, 'Ann')
|
||||
await fiftyTokens(gm, scene, { id: player.id })
|
||||
|
||||
// Only the viewport's window needs fixture bytes; 16384 px would be 262144 files.
|
||||
// The capped map is only 60x34 tiles at 32 px, so write the whole grid: no viewport edge can
|
||||
// ask for a missing tile (the old 16384 px scene only had a viewport window, thousands of files).
|
||||
writeTileGrid(stateDir, {
|
||||
scene: scene.id, artVersion: scene.art_version, size: scene.tile_size,
|
||||
x0: 240, x1: 280, y0: 235, y1: 280,
|
||||
x0: 0, x1: Math.ceil(scene.w / scene.tile_size) - 1,
|
||||
y0: 0, y1: Math.ceil(scene.h / scene.tile_size) - 1,
|
||||
})
|
||||
|
||||
const browser = await launchBrowser()
|
||||
@@ -134,8 +137,8 @@ test('50-token fog measurement on a 16384 px map (headless SwiftShader, not the
|
||||
)
|
||||
const initial = await fogState(page)
|
||||
assert.equal(initial.tokens, 50, `the client draws 50 tokens: ${initial.tokens}`)
|
||||
assert.ok(initial.cells > 400, `a 16384 px map explored cells: ${initial.cells}`)
|
||||
assert.ok(initial.fullMs > 0, `the 512x512 fog snapshot was repainted: ${initial.fullMs}`)
|
||||
assert.ok(initial.cells > 300, `the Full HD map's explored cells: ${initial.cells}`)
|
||||
assert.ok(initial.fullMs > 0, `the 60x34 fog snapshot was repainted: ${initial.fullMs}`)
|
||||
|
||||
const real = await cadence(page, 120)
|
||||
await cdp.send('Emulation.setCPUThrottlingRate', { rate: 4 })
|
||||
@@ -144,7 +147,7 @@ test('50-token fog measurement on a 16384 px map (headless SwiftShader, not the
|
||||
assert.deepEqual(errors, [])
|
||||
|
||||
console.log(
|
||||
`fogbench (#76): 16384px map (512x512 cells), 50 tokens, 412x869 dpr2.625, ` +
|
||||
`fogbench (#76): Full HD map 1920x1080 (60x34 cells), 50 tokens, 412x869 dpr2.625, ` +
|
||||
`SwiftShader: fog snapshot=${initial.fullMs.toFixed(3)}ms exploredCells=${initial.cells} ` +
|
||||
`frames real median=${real.median.toFixed(1)}ms p95=${real.p95.toFixed(1)}ms ` +
|
||||
`4xCPU median=${throttled.median.toFixed(1)}ms p95=${throttled.p95.toFixed(1)}ms ` +
|
||||
|
||||
Reference in New Issue
Block a user