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

Fixed Unnecessary SizeChanged Event Triggering #27476

Merged
merged 6 commits into from
Feb 14, 2025

Conversation

Dhivya-SF4094
Copy link
Contributor

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

Before  After 
 
27223_BeforeFix.mp4
  
27223_AfterFix.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 30, 2025
Copy link
Contributor

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.

@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 30, 2025
@Dhivya-SF4094 Dhivya-SF4094 marked this pull request as ready for review January 31, 2025 14:17
@Dhivya-SF4094 Dhivya-SF4094 requested a review from a team as a code owner January 31, 2025 14:17
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

rmarinho commented Feb 3, 2025

/rebase

@rmarinho
Copy link
Member

rmarinho commented Feb 3, 2025

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Width = bounds.Width;
Height = bounds.Height;

SizeAllocated(Width, Height);
Copy link
Member

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.

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/rebase

@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen merged commit 86f2b95 into dotnet:main Feb 14, 2025
119 of 123 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SizeChanged event fires when size hasn't changed
8 participants