-
Notifications
You must be signed in to change notification settings - Fork 49
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] App crash when an element is removed from its parent layout #97
Comments
Are there any updates regarding this issue? |
The same issue in RGPopup.Maui: The fix commits: |
is this issue getting any attention at all? |
For anyone stumbling upon this issue the workaround is to modify the mappers thusly (from here) //Workaround for: https://github.com/LuckyDucko/Mopups/issues/97
#if IOS
Mopups.Platforms.iOS.PopupPageHandler.Mapper.AppendToMapping("FixingMopupCrash", (handler, view) =>
{
(view as Page).Appearing += (s, e) =>
{
var eventName = "DescendantRemoved";
var eventInfo = typeof(Element).GetEvent(eventName);
var descendantRemovedEvent = typeof(Element).GetField(eventName, BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (descendantRemovedEvent.GetValue(view) is not Delegate eventDelegate)
{
return;
}
foreach (var d in eventDelegate.GetInvocationList())
{
eventInfo.RemoveEventHandler(view, d);
}
};
});
#endif |
a try catch around this could would likely fix it - https://github.com/LuckyDucko/Mopups/blob/66f585d8c6ccce90a711400b0d14ea378fdb3e5d/Mopups/Mopups.Maui/Platforms/MacCatalyst/MacOSMopups.cs#L152C1-L153C62 I dont personally have this issue, and havnt got the time to test/ fix/ create a PR. So anyone who actually has this issue, take a look at this, and if this does fix it, submit a PR |
Given the bug is on iOS I highly doubt that will fix it |
Exception "MauiContext should have been set on parent" when removing a child from its parent layout on iOS
Description:
When a child is removed from its parent layout on iOS, an exception "MauiContext should have been set on parent" is thrown. Upon investigation, it seems that the issue arises during the cleanup process by Maui when attempting to clean a child that has already been cleaned by Mopups.
Proposed Solution:
To address this issue, I suggest stopping listening the 'DescendantRemoved' event and the child handler cleanup in the iOS implementation of IPopupPlatform. By doing so, Maui will be able to properly handle the cleanup of the removed view.
Environment:
Repro
ReproMopups.zip
Steps to reproduce
A label will be added with the first tap, but after the second the app will crash trying to remove the label from its parent layout.
The text was updated successfully, but these errors were encountered: