[android] compute HasRtlSupport once on startup #3801
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Previously we were calculating:
Multiple times for every
Label
,Entry
, or related controls.Context.ApplicationInfo
pulls values from theAndroidManifest.xml
for the entire Android application, so this isn't a value that would
not change after startup -- or for different controls.
https://developer.android.com/reference/android/content/pm/ApplicationInfo#flags
https://developer.android.com/reference/android/content/pm/ApplicationInfo#FLAG_SUPPORTS_RTL
Let's move this method to be a
static readonly
field in a new staticclass. It will lazily be evaluated when the new class is accessed, and
only once per application run.
Results
Running
ViewHandlerBenchmark
on a Pixel 5 device:-
Using dotnet/maui/main before these changes+
Using these changesI tried a few times, and I'm not sure I'm able to see a measurable
difference launching
Maui.Controls.Sample.SingleProject.csproj
overand over. But this change seems low risk, worth adding in.
PR Checklist
Does this PR touch anything that might affect accessibility?
No