test(e2e): count distinct tile URLs, tolerate transient image errors
The mobile map gate compared the cumulative request counter to the wanted window, but the #70 rule re-asks a tile whose 403 became allowed when the explored frame lands after the first window, so a correct load can be 481 attempts for a 480-tile window (seen once on a loaded host). Expose data-tile-distinct and assert that no tile URL is fetched twice; the no-retry proof stays the 403 test's per-URL count. The console collector now ignores the browser's network-level resource line, like the fog suites: a transient tile error is explicitly tolerated by the tile contract, and the page wait already reflects it.
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
// the gate's answer for those tiles changed, so exactly those denied tiles are asked once more.
|
||||
//
|
||||
// The e2e contract on the canvas: `data-tiles` (`loading`/`ready`/`idle`) and
|
||||
// `data-tile-requests` (how many fetches this page ever made). `ready` means this pass is complete:
|
||||
// `data-tile-requests` (how many fetches this page ever made) and `data-tile-distinct` (how many
|
||||
// distinct tile URLs it fetched; the #70 re-ask after newly explored cells is a second request for
|
||||
// the same URL, so requests may be larger). `ready` means this pass is complete:
|
||||
// every wanted tile has a terminal answer (`ok`, `denied`, or a stored transient `error` that waits
|
||||
// for a new window or a reconnect). A stored `error` must not keep `ready` away, or one host hiccup
|
||||
// would hang the tile-size gate (a) and every e2e readiness wait.
|
||||
@@ -24,6 +26,9 @@ import { fogOf } from '../../slices/fog.ts'
|
||||
const textureCache = new Map<string, Texture>()
|
||||
/** Fetches made by this page; the cache-survives-reconnect proof reads it. */
|
||||
let requests = 0
|
||||
/** Distinct tile URLs fetched. A #70 retry after newly explored cells asks the same URL again, so
|
||||
* `requests` may exceed this; a duplicate *tile* would not. */
|
||||
const requestedUrls = new Set<string>()
|
||||
|
||||
function loadImage(src: string): Promise<HTMLImageElement> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -36,6 +41,7 @@ function loadImage(src: string): Promise<HTMLImageElement> {
|
||||
|
||||
async function fetchTile(url: string): Promise<TileLoadResult> {
|
||||
requests += 1
|
||||
requestedUrls.add(url)
|
||||
try {
|
||||
// The browser's own image loader fetches and decodes off the JS path; one `onload` per tile is
|
||||
// the cheapest way to get 480 phone-viewport tiles onto the GPU. The response body is not
|
||||
@@ -65,6 +71,7 @@ export const renderModule: RenderModule = {
|
||||
let frame = 0
|
||||
|
||||
canvas.dataset['tileRequests'] = String(requests)
|
||||
canvas.dataset['tileDistinct'] = String(requestedUrls.size)
|
||||
|
||||
const scheduler = new TileScheduler({
|
||||
load: fetchTile,
|
||||
@@ -109,6 +116,7 @@ export const renderModule: RenderModule = {
|
||||
|
||||
scheduler.setDesired(wanted.map(tile => tile.url))
|
||||
canvas.dataset['tileRequests'] = String(requests)
|
||||
canvas.dataset['tileDistinct'] = String(requestedUrls.size)
|
||||
canvas.dataset['visibleTiles'] = String(wanted.length)
|
||||
|
||||
// `ready` means this pass is done, not that every tile painted: a transient `error` is
|
||||
|
||||
Reference in New Issue
Block a user