Skip to content

Map: route-polyline reconcile/width algorithm duplicated verbatim across Google and MapLibre renderers #1906

Description

@bmander

From the 2026-07-16 debt review (finding 6). Severity: high (maintenance).

GoogleMapRenderer.kt:302-324,779-790 and MapLibreRenderer.kt:211-239,246-256 carry the identical ~60-line algorithm: identity/equality early-out, reconcileEqualItems diff, per-index width comparison against renderedRouteWidths, retained-native width patching, the three-field state update, and the camera-settle width-resync loop. #1865 introduced the copy in both flavors; #1892 grew it in parallel (the renderedRouteWidthScale: Float?renderedRouteWidths: List<Float> migration was applied twice), and one #1865 review fix had to be applied to both copies — the hazard has already materialized.

The platform-specific surface is only three operations: create a native line, remove one, set its width.

Fix (medium): a RoutePolylineReconciler<NativeLine> beside the existing map/render/ListReconciliation.kt, parameterized by those three lambdas. Lower-priority echo: the renderedStops/renderedFocusedStopId/renderedScaleWithZoom dedup-guard triple copied between GoogleRouteStopBitmapLayer.kt:66-93 and MapLibreRouteStopCircleLayer.kt:99-109 (drawing strategies genuinely differ there).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions