Skip to content
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

scale bar: slight performance improvement #235

Merged
merged 1 commit into from
Jan 8, 2025
Merged

Conversation

westnordost
Copy link
Collaborator

@westnordost westnordost commented Jan 8, 2025

after all, the defaultScaleBarMeasures is now called every frame.

(If it wasn't @Composable, it could also be remembered)


I was previously looking into performance improvements on the scalebar, after all, quite a lot is going on there. But basically any attempt to let the scalebar compose less often is sabotaged by the fact that any change in latitude or zoom will make it recompose anyway, as the metersPerDp changes.

metersPerDp could maybe be rounded, the trick would be to find out at which precision it starts to matter (i.e. be visible on the scalebar). Then, it would generally not recompose when scrolling around in an area, only when one zooms.

@sargunv
Copy link
Owner

sargunv commented Jan 8, 2025

Haven't looked at the PR yet, but:

metersPerDp could maybe be rounded, the trick would be to find out at which precision it starts to matter (i.e. be visible on the scalebar). Then, it would generally not recompose when scrolling around in an area, only when one zooms.

derivedStateOf could possibly be useful here? input is metersPerDp, outputs are bar width and text. Bar width (dp) could be rounded based on density.

@sargunv sargunv merged commit 206671f into main Jan 8, 2025
9 checks passed
@sargunv sargunv deleted the scalebar-performance branch January 8, 2025 17: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.

2 participants