Skip to content

[Windows]Fixed the ViewExtensions RotateYTo and RotateXTo with length 0 crashes #30167

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Ahamed-Ali
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Root Cause of the issue

  • When RotateYTo is dynamically updated with a duration of 0, it causes the value calculation in Tweener class to result in NaN. This NaN value is then passed to the UpdatedTransformation method on Windows, where the subtraction between the PlaneProjection's Rotation property and the MAUI rotation leads to an ArgumentException.

https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/Tweener.cs#L124

Description of Change

  • If the calculated value is NaN, a defensive check is added to prevent invalid transformations from being applied. This ensures that when any rotation value is NaN (Not a Number), it is skipped. On subsequent updates, a valid value will be used, allowing the transformation to proceed as expected.

Issues Fixed

Fixes #18420

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
CrashOccured.mp4
NoCrashwithFix.mp4

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

Hey there @@Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 24, 2025
@@ -37,6 +37,10 @@ public static void UpdateTransformation(this FrameworkElement frameworkElement,
// rotation values are set, but the aforementioned functionality will be lost.
if (Math.Abs(view.RotationX) != 0 || Math.Abs(view.RotationY) != 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason this is not

Suggested change
if (Math.Abs(view.RotationX) != 0 || Math.Abs(view.RotationY) != 0)
if (Math.Abs(rotationX) != 0 || Math.Abs(rotationY) != 0)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, I have reused the local variable @MartyIX

if (double.IsNaN(rotationX) || double.IsNaN(rotationY) || double.IsNaN(rotation))
{
return;
}
Copy link
Contributor

@MartyIX MartyIX Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw: Given your patch, is it safe to pass NaN here:

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's safe to pass NaN in this case because no mathematical operations are performed on it, so no exception occurs. A valid value will be updated during the subsequent continuous updates. @MartyIX

@@ -0,0 +1,35 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 18420, "[Windows]ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows", PlatformAffected.UWP)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Issue(IssueTracker.Github, 18420, "[Windows]ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows", PlatformAffected.UWP)]
[Issue(IssueTracker.Github, 18420, "[Windows] ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows", PlatformAffected.UWP)]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

{
public Issue18420(TestDevice device) : base(device) { }

public override string Issue => "[Windows]ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public override string Issue => "[Windows]ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows";
public override string Issue => "[Windows] ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review June 25, 2025 08:01
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner June 25, 2025 08:01
@Ahamed-Ali Ahamed-Ali requested review from rmarinho and PureWeen June 25, 2025 08:01
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 platform/windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windows]ViewExtensions RotateYTo and RotateXTo with length 0 crashes on Windows
3 participants