Busy maps: no link labels or fiber dots above 1,000 lines on screen

On a save with 2,700 lines on screen, Firefox spent about 95% of each
frame painting, and the dotted line on lit fiber (~160 ms) and the link
labels (~55 ms) were half of it, in a tangle where neither can be read.

draw() now counts the lines it would paint (linesOnScreen(), same box and
margin as its own culling, boxes cached on the geometry) and above
MAP_BUSY = 1000 leaves out both. They come back as soon as fewer lines
show, zooming in for instance. The selected link keeps its label.

Firefox Developer Edition headless, 1600x900 at DPR 2, player save, median
of 3x9 frames: save view 414 -> 214 ms, pan 472 -> 238, zoom 0.6 269 -> 181,
New York zoom 2 213 -> 107, selected link 412 -> 201. Under the threshold
pixels are identical (canvas SHA-1): zoom 3.2 and 6 on the player save, six
views of the big-network fixture.
This commit is contained in:
Hugues 2026-10-27 14:03:04 +01:00
parent 22817c83c5
commit a3dd1dd810
3 changed files with 40 additions and 5 deletions

View file

@ -121,6 +121,31 @@ test('the map keeps fiber capacities for one frame only, and skips links above o
assert.deepEqual(errors, []);
});
test('a map with more than MAP_BUSY lines on screen leaves out link labels and fiber dots, and they come back', () => {
const { ev, errors } = load();
bigNet(ev);
// Spy on the two things that go: the dotted line on lit fiber and the link labels.
ev("window.__dots=0;window.__labels=[];ctx.setLineDash=d=>{if(d.length===2&&d[0]===1&&d[1]===6)__dots++;};ctx.fillText=t=>{if(/ DF$/.test(t))__labels.push(t);}");
const frame = () => ev("__dots=0;__labels=[];draw(0);JSON.stringify([__dots,__labels.length])");
const view = "cam.x=(CITY.fra.x+CITY.lon.x)/2;cam.y=(CITY.fra.y+CITY.lon.y)/2;cam.z=1.6;";
const lines = () => ev("(()=>{const PI=pairIdx();return linesOnScreen(linkGroups().map(g=>linkGeom(g[0],PI.get(edgeKey(g[0])))),visibleKs());})()");
ev("const ps=[['fra','ams'],['ams','lon'],['lon','par'],['par','fra'],['fra','lon'],['ams','par']];for(let i=0;i<20;i++){const [a,b]=ps[i%6];S.links.push({id:'dfB'+i,a,b,kind:'df',own:true,km:kmBetween(a,b),ready:0,ch:['zr4']});}compute()");
ev(view);
assert.ok(lines() < ev('MAP_BUSY'));
const [dots, labels] = JSON.parse(frame());
assert.ok(dots >= 20 && labels >= 20, 'a normal map shows them');
ev("const ps2=[['fra','ams'],['ams','lon'],['lon','par'],['par','fra'],['fra','lon'],['ams','par']];for(let i=20;i<MAP_BUSY+20;i++){const [a,b]=ps2[i%6];S.links.push({id:'dfB'+i,a,b,kind:'df',own:true,km:kmBetween(a,b),ready:0,ch:['zr4']});}compute()");
ev(view);
assert.ok(lines() > ev('MAP_BUSY'));
assert.equal(frame(), '[0,0]', 'a tangle of lines does not');
ev("UI.sel={type:'link',id:'dfB3'}");
assert.equal(frame(), '[0,1]', 'except the label of the selected link');
ev("UI.sel=null;S.links=S.links.filter(l=>!/^dfB/.test(l.id)||+l.id.slice(3)<20);compute()");
ev(view);
assert.deepEqual(JSON.parse(frame()), [dots, labels], 'back as soon as fewer lines show');
assert.deepEqual(errors, []);
});
test('long lists in the NOC dashboard show 100 rows at a time and grow on request', () => {
const { ev, errors } = load();
bigNet(ev);