Skip to content

fix(ios): prevent crash on Google Maps animated gradient polyline#84

Merged
lodev09 merged 2 commits into
mainfrom
fix/ios-google-maps-animated-polyline-crash
Jun 16, 2026
Merged

fix(ios): prevent crash on Google Maps animated gradient polyline#84
lodev09 merged 2 commits into
mainfrom
fix/ios-google-maps-animated-polyline-crash

Conversation

@lodev09

@lodev09 lodev09 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Fixes ENG-1150.

Summary

Fixes a native iOS crash (EXC_BAD_ACCESS / GMSModelStyleBuilder couldNotInstantiate) on animated Google Maps gradient polylines, surfaced by TestFlight crash reports in the Lugg Mover app (ENG-1150).

Each display-link tick assigned _polyline.path = path then _polyline.spans = spans. Setting the new (shorter) path while the previous tick's spans were still attached makes Google Maps rebuild span models for segments that no longer exist → throws in GMSModelStyleBuilder. The empty-path branch (headDist <= tailDist) was the worst case: it shrank the path to empty but left stale spans.

The fix preserves the gradient rather than falling back to a solid stroke:

  • Clear _polyline.spans = nil before swapping to a shorter/empty path, then reassign spans once the new path is set, so path and spans are never inconsistent.
  • Guard the zero-segment case (clear spans, set path, return).
  • Drop duplicate adjacent coordinates while building the path (zero-length segments also fail model-style instantiation).
  • Apply the same hardening to the non-animated update path; createGradientSpans now keys off the deduped path's actual segment count.

Also adds an example smoke test: the gradient route is sliced to the path ahead of the moving truck, so coordinates mutate mid-animation — mirroring the live-route scenario from the crash.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

  • Ran the example on iOS (Google provider) with the truck-driven gradient polyline; gradient renders and animates with no crash.
  • Note: the original crash reproduces under live GPS on device; the fix removes the path/spans inconsistency window identified in the symbolicated backtrace.

Screenshots / Videos

N/A

Checklist

  • I tested on iOS
  • I tested on Android
  • I tested on Web
  • I updated the documentation (if needed)

lodev09 added 2 commits June 17, 2026 02:51
Clear GMSPolyline spans before swapping a shorter path so Google Maps
never rebuilds span models against missing segments (GMSModelStyleBuilder
couldNotInstantiate -> EXC_BAD_ACCESS). Guard zero-segment paths and drop
duplicate adjacent coordinates in both animated and static updates.
Gradient rendering is preserved.
Slice the animated route ahead of the moving truck so the polyline
coordinates mutate mid-animation, mirroring the live-route scenario
from the Mover crash. Bumps example Podfile.lock to beta.16.
@lodev09 lodev09 merged commit 9926c45 into main Jun 16, 2026
3 checks passed
@lodev09 lodev09 deleted the fix/ios-google-maps-animated-polyline-crash branch June 16, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant