-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android/core: Couple a sequenced scheduler to the lifetime of a GeoJSON source #2182
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Bloaty Results (iOS) 🐋Compared to main
Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-2182-compared-to-main.txt |
Bloaty Results 🐋Compared to main
Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2182-compared-to-main.txtCompared to d387090 (legacy)
Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-2182-compared-to-legacy.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation pointer of GeoJSONSource
is swapped out when new data arrives. Do you know why they chose that? Wouldn't it make more sense to keep the implementation around for the duration of the parent object, but replace the data? Then the scheduler could also be part of the implementation class without this problem.
It's to support both I can probably move the sequenced scheduler into the base class |
… a GeoJSON source (maplibre#2182)" This reverts commit 4e9392e.
… a GeoJSON source (maplibre#2182)" This reverts commit 4e9392e.
The Android SDK location indicator is constructed using a GeoJSON source. Animation events for things like the pulsing circle trigger a GeoJSON source update within the core.
GeoJSONData
gets created to perform some async work on a sequenced scheduler.In the case described above, a thread will be requested from the sequenced scheduler. As almost nothing else uses it (GeoJSON and logging, really), it is almost certain all threads in the scheduler's ring buffer have been destructed. So the scheduler creates a new thread and returns it.
GeoJSONData
does its work, quickly, and is disposed of. That leaves the scheduler thread with 0 references and it too is destructed. This results in the library creating threads that live for less than a millisecond constantly while an animated location indicator is on the screen.This PR couples a sequenced scheduler directly with the GeoJSON source, keeping the thread used alive for the duration of the source. By not constantly creating and destroying threads, any potential performance impact from that activity is eliminated.