HSLdevcom / digitransit-ui

Digitransit UI ("Reittiopas.fi")
https://www.reittiopas.fi/
Other
237 stars 130 forks source link

Optimize stops near you rendering a bit #5015

Closed vesameskanen closed 3 weeks ago

vesameskanen commented 3 weeks ago

Stops near you view has bad update flow and the whole page is rendered constantly. This is problematic, because the map collects thousands of route patterns and decodes thousands of geometry points from each pattern. Such computation is very expensive.

This PR introduces two fixes which mitigate the problems partly:

  1. View navigation no longer always triggers full page render. Only when refecth stops button should appear/disapper, rendering occurs.
  2. Polyline conversion to leaflet objects is now done in the effect which monitors relevant changes. Previously, every render cycle executed the heavy computation.

In the future, the view should be split into smaller components with sensible data dependencies. For example, map does not need re-rendering when departure times change.