-
Notifications
You must be signed in to change notification settings - Fork 2k
[macOS] Fix crash when setting window properties #21357
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -198,6 +198,10 @@ double GetSizeCoordinate(BindableProperty property) | |||
| return ValidatePositive(coord); | ||||
| } | ||||
|
|
||||
| #if MACCATALYST | ||||
| bool _frameUpdateInProgress = false; | ||||
| #endif | ||||
|
|
||||
| int _batchFrameUpdate = 0; | ||||
|
|
||||
| void IWindow.FrameChanged(Rect frame) | ||||
|
|
@@ -206,9 +210,26 @@ void IWindow.FrameChanged(Rect frame) | |||
| var y = Y; | ||||
| var width = Width; | ||||
| var height = Height; | ||||
|
|
||||
| #if MACCATALYST | ||||
| // MacCatalyst does not support setting window properties: X, Y, width, and height. | ||||
| if (_frameUpdateInProgress) { | ||||
| X = frame.X; | ||||
| Y = frame.Y; | ||||
| Width = frame.Width; | ||||
| Height = frame.Height; | ||||
|
|
||||
| return; | ||||
| } | ||||
|
Comment on lines
+216
to
+223
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the difference between setting this and using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't recall specifically but I think it was that
Does it make sense to you? I can try to dig into it again if that doesn't sound right but I don't have a solid grasp of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, my VS Code on macOS got totally broken, I can't debug MAUI projects anymore. Anyway, I think it's good to put a breakpoint on L217 to see the stacktrace there and if this PR makes sense or not. I'll try to work on this PR later. I spent 2 hours and I couldn't get that stacktrace. I'm out of time for now.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I got bitten by #22033. |
||||
| #endif | ||||
|
|
||||
| if (new Rect(x, y, width, height) == frame) | ||||
| return; | ||||
|
|
||||
| #if MACCATALYST | ||||
| _frameUpdateInProgress = true; | ||||
| #endif | ||||
|
|
||||
| _batchFrameUpdate++; | ||||
|
|
||||
| SetPropertyChanging(XProperty, nameof(X), x, frame.X); | ||||
|
|
@@ -235,6 +256,10 @@ void IWindow.FrameChanged(Rect frame) | |||
| SizeChanged?.Invoke(this, EventArgs.Empty); | ||||
| } | ||||
|
|
||||
| #if MACCATALYST | ||||
| _frameUpdateInProgress = false; | ||||
| #endif | ||||
|
|
||||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||||
| void SetPropertyChanging(BindableProperty property, string name, double oldValue, double newValue) | ||||
| { | ||||
|
|
||||
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.
Is there a way to use the
_batchFrameUpdatefield? That is already being set when the frame is updating.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.
I'll try if it works.