[BUG] Popup not showing in NavigatedTo event on Shell.
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Did you read the “Reporting a bug” section on Contributing file?
- I have read the “Reporting a bug” section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
In the NavigatedTo event on the Shell, when I show the Popup it doesn’t show up and when I close it I get an exception.
Expected Behavior
The Popup should be displayed when the Popup is displayed in the NavigatedTo event on the Shell. The Popup should be closed without throwing an exception when closing the Popup.
Steps To Reproduce
Please follow the steps below to reproduce.
- Create MainPage as Shell.
- Call the Page’s ShowPopup method in the NavigatedTo event.
- Do something.
- Call the Popup’s Close method in the NavigateTo event.
Popup is not displayed at 3. The following exception occurs at 4.
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
[mono-rt] at CommunityToolkit.Maui.Views.Popup.CommunityToolkit.Maui.Core.IPopup.OnClosed(Object result) in /_/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs:line 268
[mono-rt] at CommunityToolkit.Maui.Views.Popup.OnClosed(Object result, Boolean wasDismissedByTappingOutsideOfPopup) in /_/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs:line 230
[mono-rt] at CommunityToolkit.Maui.Views.Popup.Close(Object result) in /_/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs:line 210
[mono-rt] at MauiComm_IssueShellPopup.Page2.OnNavigatedTo(NavigatedToEventArgs args) in C:\Users\Tester\source\repos\MauiComm-IssueShellPopup\Page2.xaml.cs:line 27
[mono-rt] at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
[mono-rt] at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:line 36
[mono-rt] at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:line 36
[mono-rt] at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Java.Lang.IRunnable.cs:line 84
[mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 22
[HostConnection] HostConnection::get() New Host Connection established 0xf2968170, tid 29640
[HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2
Link to public reproduction project repository
https://github.com/cat0363/MauiComm-IssueShellPopup
Environment
- .NET MAUI CommunityToolkit: 5.0.0
- OS: Windows 11 Build 22621.1413
- .NET MAUI: 7.0.59
Anything else?
This problem was described based on Discussion #1116. This issue occurred on Android 11.0. Since the build environment has not been prepared, it cannot be confirmed on iOS.
Even in the same Navigate To event, if I make the Main Page as a Navigation Page instead of Shell, the Popup shows up just fine.
Try changing the code uploaded on github to:
[App.xaml.cs]
// MainPage = new AppShell();
MainPage = new NavigationPage(new Page1());
[Page1.xaml.cs]
// await Navigation.PushAsync(new Page2(), false);
await Shell.Current.Navigation.PushAsync(new Page2(), false);
Below are the execution results of NavigationPage and Shell respectively.
[Execution result on NavigationPage]
[Execution result on Shell]
You can’t see it in the video, but in the shell case, it’s throwing an exception.
Issue Analytics
- State:
- Created 6 months ago
- Comments:16 (13 by maintainers)
Thanks @cat0363!!
Nope, you did it perfectly! In fact, I see Vlad has already approved it ❤️
Just FYI - we have a bug in our CI/CD pipeline that our Tizen expert, Jay Cho, is going to fix next week. Once our CI/CD bug is fixed, we’ll merge the PR!
No problem! Check out this video https://www.youtube.com/watch?v=8x6V5IOuXog
I highly recommend GitHub Desktop for interacting with
git
. I’ve used GitHub Desktop for years; it’s much more intuitive than usinggit
in the command line 💯