perf: Reduce allocations across Shimmer, Popup, TabView, and TextInputLayout#389
Open
PaulAndersonS wants to merge 1 commit into
Open
perf: Reduce allocations across Shimmer, Popup, TabView, and TextInputLayout#389PaulAndersonS wants to merge 1 commit into
PaulAndersonS wants to merge 1 commit into
Conversation
…tLayout - Shimmer: Cache Point allocations as static readonly fields in CreateWavePaint - Shimmer: Remove LINQ Cast<View>() allocation in DrawCustomViewChildren - Popup: Eliminate redundant null check and unnecessary new Page() allocations - TabView (iOS): Cache reflection GetProperties().Any() result per-type - TextInputLayout: Consolidate multiple InvalidateDrawable() calls into one Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
Tab View and Text Input Layout changes are fine |
Karthickmani97
left a comment
Collaborator
There was a problem hiding this comment.
Shimmer control changes are fine
AmalRajUmapathySelvam
approved these changes
Jun 15, 2026
AmalRajUmapathySelvam
left a comment
Collaborator
There was a problem hiding this comment.
Popup changes are fine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Root Cause of the Issue
Multiple controls have unnecessary object allocations, redundant method calls, and expensive reflection operations in hot paths that negatively impact runtime performance.
Description of Change
This PR implements 5 targeted performance improvements across 4 controls:
Shimmer – Cache
Pointallocations asstatic readonlyfieldsCreateWavePaint()previously created 2 newPointobjects on every call. Since the values are constants (e.g.,(0,0),(1,0),(0,1),(1,1)), they are now cached as static readonly fields, eliminating per-call heap allocations.Shimmer – Remove
Cast<View>()LINQ allocation inDrawCustomViewChildrenDrawCustomViewChildrenmethod called.Cast<View>()onlayout.Children, which allocates an enumerator wrapper on every call. Replaced with direct iteration and type checking.Popup – Eliminate redundant null check and unnecessary
new Page()allocationsGetMainPage()had a duplicateif (windowPage is not null)check (dead code).GetMainPage()andGetMainWindowPage()returnednew Page()as a fallback, creating garbage that callers immediately discarded. Now returnsnull, with callers updated for null-safety.TabView (iOS) – Cache
GetProperties().Any()reflection result per-typetouchViewType.GetProperties().Any(...)which uses reflection to scan all properties. Added aConcurrentDictionary<Type, bool>cache so reflection happens only once per type.TextInputLayout – Consolidate multiple
InvalidateDrawable()callsOnTextInputViewTextChangedcould callInvalidateDrawable()up to 2 times in a single invocation (once for hint state change + once for clear icon). Consolidated into a single deferred call using aneedsRedrawflag.Issues Fixed
N/A – Proactive performance improvement.
Unit Tests
Added 11 unit tests in
PerformanceOptimizationTests.cscovering: