Skip to content

fix: resync map overlay after backgrounding to fix misalignment - #713

Open
EthanShoe wants to merge 3 commits into
johanohly:mainfrom
EthanShoe:fix-mobile-arc-map-misalignment
Open

fix: resync map overlay after backgrounding to fix misalignment#713
EthanShoe wants to merge 3 commits into
johanohly:mainfrom
EthanShoe:fix-mobile-arc-map-misalignment

Conversation

@EthanShoe

@EthanShoe EthanShoe commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #712

@johanohly - Full disclosure, this code was completely vibe coded. I debugged this issue for a while with Claude and I am more opening this PR to show what actually ended up fixing the issue for me and hopefully make it easier for you to write a real fix if this code is not sufficient.

Note

Resync the map overlay after resume and stabilize overview camera fits

  • Resizes MapLibre and rebuilds Deck layers after visibility, page-show, resume, and container-size changes, then verifies canvas alignment.
  • Calculates arc-fit camera targets explicitly, jumps automatic fits, animates manual fits, and prevents interrupted moves from restoring stale padding.
  • Updates camera-controller coverage for the new fit transitions and overlapping-fit behavior.

AirTrail Helper summarized cf10d46 · AI-generated summary; verify important details.

@airtrail-helper airtrail-helper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AirTrail AI Review identified 2 new actionable issues.

How can I respond to a finding?
  • Fix it: push a new commit; AirTrail Helper will recheck the finding.
  • Question or challenge it: reply in the finding thread and mention @airtrail-helper.
  • Maintainers: resolve the thread to dismiss the finding.

Comment thread src/lib/map/camera-controller.ts Outdated
Comment thread src/lib/map/camera-controller.ts Outdated

@airtrail-helper airtrail-helper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AirTrail AI Review identified 2 new actionable issues.

How can I respond to a finding?
  • Fix it: push a new commit; AirTrail Helper will recheck the finding.
  • Question or challenge it: reply in the finding thread and mention @airtrail-helper.
  • Maintainers: resolve the thread to dismiss the finding.

const target = targetForArcs(intent.arcs, intent.projection, padding);
if (!target) return;
const MIN_OVERVIEW_ZOOM = 1;
const appliedZoom = Math.max(target.zoom, MIN_OVERVIEW_ZOOM);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium — Preserve the zoom required to fit all arcs

Clamping the computed fit zoom to 1 breaks the fit contract on narrow viewports or geographically broad datasets: bounds that require zoom below 1 are cropped, so some airports and routes remain off-screen. Use the zoom returned by cameraForBounds, or apply a minimum only when the bounds are still proven to fit.


AirTrail Helper reviewed a1c44a1 · AI-generated finding; verify important details.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is true I think. But I'm pretty sure this was also the main cause of the bug. :/

pendingVerifyTimer = null;
if (!isDeckCanvasMisaligned()) return;
if (attempt >= MAX_RESYNC_ATTEMPTS) {
window.location.reload();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium — Avoid reloading indefinitely on persistent canvas mismatch

If the two backing canvases remain more than two pixels apart—for example because their WebGL contexts apply different device-pixel or maximum-buffer sizing—this reloads the page, and the next pageshow repeats the same verification and reload indefinitely. Keep retrying or disable/recreate the overlay without navigating, rather than making persistent size equality a reload condition.


AirTrail Helper reviewed a1c44a1 · AI-generated finding; verify important details.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map and arcs/circles get misaligned on mobile after backgrounding

1 participant