Skip to content

Investigate NaN being produced internally during CRS work #2219

Description

@JaffaKetchup

During the timeline below, it was hinted at in #2208 by @maheshj01, then investigated by @mootw, that NaN was being produced internally by the following method in MapCamera:

double getZoomScale(double toZoom, double fromZoom) =>
crs.scale(toZoom) / crs.scale(fromZoom);

It appears that when this method is called with identical arguments, the result is NaN? However, for some reason, before #2182, this did not cause issues. This needs to be investigated.

The method itself also needs to be investigated - why is it the shape that it is? See comments in #2199 for more information. Does it make more sense for the method to return 1 instead of NaN or 0 when the inputs are the same?

Internal link to start of discussion for @fleaflet/maintainers only: https://discord.com/channels/951867686378409984/951879268227485707/1521558461819916458

Timeline:

  1. LatLng with double.nan in Marker/MarkerLayer triggers memory leak #2178 was opened, reporting that Markers with NaN points caused memory leaks and crashes
  2. fix: throw when LatLng is non-finite #2182 was opened and merged (resolving LatLng with double.nan in Marker/MarkerLayer triggers memory leak #2178), which introduced a check for NaN during all projections from LatLngs - this aimed to uncover the memory leak and throw instead, which was deemed an acceptable solution
  3. Many interactions throw "LatLng is not finite" error #2199 was opened, reporting that the new check triggered unexpectedly during many typical and normal interactions and configurations
  4. fix: LatLng is not finite exception #2208 was opened, which fixed some cases of the NaN being produced internally, partially fixing Many interactions throw "LatLng is not finite" error #2199
  5. perf: cache zoom-independent marker projections in MarkerLayer #2213 was merged, which (in addition to unrelated issues) introduced a check for NaN on the MarkerLayer only, double fixing LatLng with double.nan in Marker/MarkerLayer triggers memory leak #2178 with a tighter scope
  6. revert: fix: throw when LatLng is non-finite #2218 was opened and merged, to revert fix: throw when LatLng is non-finite #2182, close fix: LatLng is not finite exception #2208, and fix Many interactions throw "LatLng is not finite" error #2199 - this would've reopened LatLng with double.nan in Marker/MarkerLayer triggers memory leak #2178, but perf: cache zoom-independent marker projections in MarkerLayer #2213 fixed it anyway

Metadata

Metadata

Assignees

Type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions