-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fixed Unnecessary SizeChanged Event Triggering #27476
Conversation
Hey there @Dhivya-SF4094! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/rebase |
c8023c6
to
b81310e
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Width = bounds.Width; | ||
Height = bounds.Height; | ||
|
||
SizeAllocated(Width, Height); |
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.
Should this line also be in the if? If the size is unchanged then technically nothing changed and no new allocation took place.
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.
Moved SizeAllocated(Width, Height); inside the if condition to ensure that it is only called when the width or height actually changes. This prevents unnecessary allocation when the size remains the same.
@@ -1761,11 +1761,15 @@ void UpdateBoundsComponents(Rect bounds) | |||
|
|||
X = bounds.X; |
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.
Should we wrap the whole block here as well with a check for if _frame != bounds? If nothing changes, then do nothing.
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.
Added an early exit check (if (_frame == bounds) return;) at the beginning of the method. This ensures that the update logic runs only when bounds actually changes, preventing unnecessary processing.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/rebase |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Issue Details:
The SizeChanged event was being triggered continuously even when the width and height of the element remained unchanged.
Root Cause:
The existing implementation did not verify whether the width and height had actually changed before invoking the event.
Description of Change:
A condition was added to compare the existing width and height with the new values before triggering the SizeChanged event. This ensures that the event is only fired when there is an actual change in size, preventing unnecessary event invocations.
Tested the behavior in the following platforms
- [ ] Android
- [x] Windows
- [ ] iOS
- [x] Mac
Issues Fixed:
Fixes #27223
Screenshots
27223_BeforeFix.mp4
27223_AfterFix.mp4