-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fix modal page crash during app snapshot creation #31866
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
[iOS] Fix modal page crash during app snapshot creation #31866
Conversation
|
/azp run |
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.
Pull Request Overview
Fixes a crash that occurs during iOS app snapshot creation when modal pages are displayed. The crash happens when ViewDidLayoutSubviews() attempts to call PlatformArrange() on a handler whose VirtualView has been disposed or is null.
- Added defensive null check in
ControlsModalWrapper.ViewDidLayoutSubviews()method - Follows existing defensive programming pattern used elsewhere in the same file
- Prevents
InvalidOperationExceptionduring app state transitions
|
Not sure it will help, but also it doesn't hurt? |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Failing tests are unrelated |
jsuarezruiz
left a comment
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.
@copilot Review
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
I'm quite unhappy that, after an initial prospect of a quick fix, this is now being postponed for no apparent reason and not merged. ...while our customer escalates the situation and we stand powerless |
|
@jfversluis Could you please merge this? Or is there some kind of professional support I can use to get this addressed? Then I can forward it internally to someone who has access to our Microsoft support contract. |
|
@baaaaif have you tested this? Does it resolve your issue? |
|
/rebase |
5558353 to
45be5aa
Compare
|
Unfortunately, we were never able to reproduce it ourselves. It's purely a customer issue. But as you said yourself, it doesn't hurt. And the fix takes over the check that's already implemented in Dispose and DidDismiss and is simply missing here. |
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…nt crash Co-authored-by: jfversluis <[email protected]>
…iews Co-authored-by: jsuarezruiz <[email protected]>
45be5aa to
b36e7e2
Compare
|
Thanks alot! |
…nt crash (#31866) Add null check in ControlsModalWrapper.ViewDidLayoutSubviews to prevent crash Co-authored-by: jfversluis <[email protected]> Add explanatory comment for defensive null check in ViewDidLayoutSubviews Co-authored-by: jsuarezruiz <[email protected]>
…nt crash (#31866) Add null check in ControlsModalWrapper.ViewDidLayoutSubviews to prevent crash Co-authored-by: jfversluis <[email protected]> Add explanatory comment for defensive null check in ViewDidLayoutSubviews Co-authored-by: jsuarezruiz <[email protected]>
Summary
This PR fixes a crash that occurs when iOS creates app snapshots while modal pages are displayed (e.g., when users switch between apps). The crash happens because
ViewDidLayoutSubviews()was callingPlatformArrange()without checking if the handler's VirtualView is still valid.Technical Details
Error Stack Trace:
Root Cause: During iOS snapshot creation (when app goes to background), the
ViewDidLayoutSubviews()method is called, which tries to callPlatformArrange()on a handler whose VirtualView has already been disposed or is null.Solution Implemented
Added a defensive null check in
ControlsModalWrapper.ViewDidLayoutSubviews()with explanatory comments to ensure_modal?.VirtualView is Pagebefore callingPlatformArrange(). This matches the defensive pattern already used in:Dispose()method (line 162)DidDismiss()method (line 66)Changes Made
src/Controls/src/Core/Platform/iOS/ControlsModalWrapper.csThis is a minimal, surgical change that adds defensive programming without altering any existing behavior when VirtualView is valid.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.