From 74673f3c8565a170d3876ad8c6412e2b7526c605 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sun, 15 Nov 2026 20:12:11 -0800 Subject: [PATCH] World overlay: the distance curve is computed in the projection pass, so its result is never boxed On Node 26 the engine inlined the projection pass's helpers in another order and left distanceScale out, so every label's paint scale allocated a number: 158 B per candidate per frame against the 154 B budget, where main measures 136 B. The curve now sits beside the altitude curve in snapshotAndProject, with the same arithmetic. --- src/overlays/worldOverlay.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/overlays/worldOverlay.js b/src/overlays/worldOverlay.js index d0dc9698b..39a3f626c 100644 --- a/src/overlays/worldOverlay.js +++ b/src/overlays/worldOverlay.js @@ -1968,9 +1968,25 @@ function snapshotAndProject(entry, source, viewProjection, keyhole) { : 0 : distanceFade(distance, record.distanceOptions); const cameraAltitude = _eyeHeight; - record.paintScale = entry.distanceScale - ? distanceScale(distance, entry.distanceScale) - : 1; + // The distance curve is local for the same reason as the altitude curve + // below: through a helper the engine may not inline, its result is boxed. + // `entry.distanceScale` was normalized when the entry was registered. + const scaleCurve = entry.distanceScale; + if (!scaleCurve || !Number.isFinite(distance)) { + record.paintScale = 1; + } else if ( + distance <= scaleCurve.near || + scaleCurve.far === scaleCurve.near + ) { + record.paintScale = scaleCurve.nearValue; + } else if (distance >= scaleCurve.far) { + record.paintScale = scaleCurve.farValue; + } else { + record.paintScale = + scaleCurve.nearValue + + (scaleCurve.farValue - scaleCurve.nearValue) * + ((distance - scaleCurve.near) / (scaleCurve.far - scaleCurve.near)); + } // Keep the source-configurable piecewise curve local to the projection hot // path. Passing its five doubles through a non-inlined helper boxed them for // every thumbnail candidate and broke the shared 154 B/candidate gate.