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

Exception if swipe to dismiss modal page on iOS (Simulator, real device not tested yet) #6666

Closed
AndreasReitberger opened this issue Apr 29, 2022 · 4 comments · Fixed by #6813
Labels
area-controls-modal fixed-in-6.0.312 Look for this fix in 6.0.312! platform/iOS 🍎 t/bug Something isn't working
Milestone

Comments

@AndreasReitberger
Copy link

Description

If a modal page gets dismissed with the swipe down gesture, a crash occurs on iOS.

Object reference not set to an instance of an object. (System.NullReferenceException)
at Microsoft.Maui.Controls.Platform.ModalWrapper.DidDismiss(UIPresentationController presentationController)
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply()

StackTrace

Objective-C exception thrown. Name: System.NullReferenceException Reason: Object reference not set to an instance of an object. (System.NullReferenceException)
at Microsoft.Maui.Controls.Platform.ModalWrapper.DidDismiss(UIPresentationController presentationController)
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply()

Native stack trace:
0 CoreFoundation 0x000000010fcbcd44 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x000000011cb6fa65 objc_exception_throw + 48
2 libxamarin-dotnet-debug.dylib 0x000000010b7391ef xamarin_process_managed_exception + 943
3 KlipperRemoteControl 0x0000000102712de9 _ZL31native_to_managed_trampoline_10P11objc_objectP13objc_selectorPP11_MonoMethodj + 361
4 KlipperRemoteControl 0x00000001027135c9 -[__MonoMac_NSAsyncSynchronizationContextDispatcher xamarinApplySelector] + 41
5 Foundation 0x0000000112ca53bf __NSThreadPerformPerform + 179
6 CoreFoundation 0x000000010fc29833 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
7 CoreFoundation 0x000000010fc2972b __CFRunLoopDoSource0 + 180
8 CoreFoundation 0x000000010fc28bf8 __CFRunLoopDoSources0 + 242
9 CoreFoundation 0x000000010fc232f4 __CFRunLoopRun + 871
10 CoreFoundation 0x000000010fc22a90 CFRunLoopRunSpecific + 562
11 GraphicsServices 0x000000011f8bdc8e GSEventRunModal + 139
12 UIKitCore 0x000000012823690e -[UIApplication _run] + 928
13 UIKitCore 0x000000012823b569 UIApplicationMain + 101
14 libmonosgen-2.0.dylib 0x000000010bf26b52 do_icall + 194
15 libmonosgen-2.0.dylib 0x000000010bf25b6d do_icall_wrapper + 253
16 libmonosgen-2.0.dylib 0x000000010bf17d8a interp_exec_method + 2970
17 libmonosgen-2.0.dylib 0x000000010bf1600f interp_runtime_invoke + 239
18 libmonosgen-2.0.dylib 0x000000010be0dcfb mono_jit_runtime_invoke + 1227
19 libmonosgen-2.0.dylib 0x000000010bd30498 mono_runtime_invoke_checked + 136
20 libmonosgen-2.0.dylib 0x000000010bd3723b mono_runtime_exec_main_checked + 107
21 libmonosgen-2.0.dylib 0x000000010be70192 mono_jit_exec + 354
22 libxamarin-dotnet-debug.dylib 0x000000010b74d0ad xamarin_main + 1949
23 KlipperRemoteControl 0x00000001027a4964 main + 52
24 dyld 0x000000010b320f21 start_sim + 10
25 ??? 0x0000000202cc251e 0x0 + 8636867870
26 ??? 0x0000000000000003 0x0 + 3

Style for the modal page => ModalPageStyle

<?xml version="1.0" encoding="utf-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    
    xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
    >
    <Style TargetType="Page" ApplyToDerivedTypes="True">
        <Setter Property="Padding" Value="0"/>
        <Setter Property="BackgroundColor" Value="{AppThemeBinding Light={DynamicResource White}, Dark={DynamicResource Black}}" />
    </Style>

    <Style TargetType="NavigationPage">
        <Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={DynamicResource White}, Dark={DynamicResource Black}}" />
        <Setter Property="BarTextColor" Value="{AppThemeBinding Light={DynamicResource PrimaryColor}, Dark={DynamicResource White}}" />
        <Setter Property="IconColor" Value="{AppThemeBinding Light={DynamicResource PrimaryColor}, Dark={DynamicResource White}}" />
    </Style>

    <Style TargetType="TabbedPage">
        <Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={DynamicResource White}, Dark={DynamicResource Black}}" />
        <Setter Property="BarTextColor" Value="{AppThemeBinding Light={DynamicResource PrimaryColor}, Dark={DynamicResource White}}" />
        <Setter Property="UnselectedTabColor" Value="{AppThemeBinding Light={DynamicResource LightGray}, Dark={DynamicResource DarkGray}}" />
        <Setter Property="SelectedTabColor" Value="{AppThemeBinding Light={DynamicResource DarkGray}, Dark={DynamicResource LightGray}}" />
    </Style>

    <Style x:Key="DefaultPageStyle" TargetType="ContentPage">
        <Setter Property="BackgroundColor" Value="{AppThemeBinding Light={DynamicResource White}, Dark={DynamicResource Black}}" />
    </Style>

    <Style x:Key="ModalPageStyle" TargetType="ContentPage" BasedOn="{StaticResource DefaultPageStyle}">
        <Setter Property="Shell.PresentationMode" Value="ModalAnimated" />
        <Setter Property="ios:Page.ModalPresentationStyle" Value="{OnIdiom Tablet=Automatic, Default=FormSheet}" />
    </Style>
</ResourceDictionary>

Steps to Reproduce

  1. Apply the style to a ContentPage
  2. Open the page with the ShellNavigationManger (Shell.Current.GoTo....)
  3. Swipe down to dismiss

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, I was not able test on other platforms

Affected platform versions

iOS 15.4

Did you find any workaround?

This bug was already in Xamarin.Forms, but it was fixed a few releases ago in Xamarin.Forms.
Maybe this helps.

Relevant log output

No response

@AndreasReitberger AndreasReitberger added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 29, 2022
@jfversluis
Copy link
Member

jfversluis commented May 2, 2022

@AndreasReitberger do you happen to have a link to the Xamarin.Forms one?

Probably this one: xamarin/Xamarin.Forms#14527

Checking what happened now...

@jfversluis jfversluis added platform/iOS 🍎 area-controls-modal and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels May 2, 2022
@AndreasReitberger
Copy link
Author

@jfversluis
xamarin/Xamarin.Forms#12300
xamarin/Xamarin.Forms#14295 (different issue, but also related to modal pages on iOS)

Thanks for looking into this!

@jfversluis
Copy link
Member

Is that 14295 also fixed for Forms or is that one still open?

I tried to apply the fix I did for Forms on this one, but seems that doesn't work. So this bug might be slightly different unfortunately.

@jfversluis jfversluis added this to the 6.0.300 milestone May 2, 2022
@AndreasReitberger
Copy link
Author

In Xamarin.Forms it's still a bug. But I haven't tried it in MAUI yet, because at the moment the app crashes afterwards closing the modal.
Once this is fixed, I'll try it and open a new issue if needed.

Best,
Andreas

@ghost ghost locked as resolved and limited conversation to collaborators Jun 9, 2022
@samhouts samhouts added the fixed-in-6.0.312 Look for this fix in 6.0.312! label Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-modal fixed-in-6.0.312 Look for this fix in 6.0.312! platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants