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

perf: MAUI MotionCanvas - only fetch density from MainDisplayInfo when changed #1626

Merged

Conversation

Kay-STL
Copy link
Contributor

@Kay-STL Kay-STL commented Oct 7, 2024

Currently, the MAUI MotionCanvas queries MainDisplayInfo on every paint in order to fetch the screen density.
Querying MainDisplayInfo on Android (11, at least) drops into Java interop to call system services - this can take a decent chunk of time, occasionally upwards of 15% of the total paint time in the application I'm profiling.

This PR tweaks the MotionCanvas to query MainDisplayInfo once in the constructor, then register a MainDisplayInfoChanged handler to update it if truly necessary.

Tested on Android, iOS, and Windows with no issues.

@beto-rodriguez
Copy link
Owner

occasionally upwards of 15% of the total paint time in the application I'm profiling

Pff that is an amazing improvement, thanks for the PR

@beto-rodriguez beto-rodriguez merged commit 7c1228a into beto-rodriguez:dev Oct 7, 2024
4 checks passed
@Kay-STL Kay-STL deleted the perf/motionCanvasDensity branch October 7, 2024 23:58
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