Rallista / maplibre-compose-playground

Composable MapLibre for Android Kotlin.
Mozilla Public License 2.0
6 stars 3 forks source link

Converted static location engine to scheduled instead of at fixed rate #44

Closed Archdoog closed 1 month ago

Archdoog commented 1 month ago

There's a reasonable discussion on differences here: https://stackoverflow.com/questions/22486997/what-is-the-difference-between-schedule-and-scheduleatfixedrate.

Android studio says:

Use of scheduleAtFixedRate is strongly discouraged because it can lead to unexpected behavior when Android processes become cached (tasks may unexpectedly execute hundreds or thousands of times in quick succession when a process changes from cached to uncached); prefer using schedule

Which I believe to have seen in ferrostar https://github.com/stadiamaps/ferrostar/pull/213.

As a result, it seems better to allow a delay in locations than unexpectedly get "hundreds or thousands" concurrent runs when this case occurs.

Happy to hear other/better ideas here as well.

ianthetechie commented 1 month ago

After a review of the docs, you are correct. I missed this and the API did not actually do what I thought it did ;)

However, I do not think this is directly related to the issue in Ferrostar. I've commented with my findings over there.