question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Popup not showing in NavigatedTo event on Shell.

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the “Reporting a bug” section on Contributing file?

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.

  1. Create MainPage as Shell.
  2. Call the Page’s ShowPopup method in the NavigatedTo event.
  3. Do something.
  4. 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]

https://user-images.githubusercontent.com/125236133/228179615-002a3aca-d252-4ef0-9483-d0f2132652af.mp4

[Execution result on Shell]

https://user-images.githubusercontent.com/125236133/228179580-b8c07818-a980-4a7e-8edf-f6d325cda431.mp4

You can’t see it in the video, but in the shell case, it’s throwing an exception.

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
brminnickcommented, Jun 9, 2023

Thanks @cat0363!!

I’m sorry if I made a mistake in creating a PR. Thank you.

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!

1reaction
brminnickcommented, Jun 8, 2023

Hi, @brminnick Thank you for your reply. This is my first time creating a PR. What should I refer to? I hope I can be of some help.

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 using git in the command line 💯

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appearing Event is not getting called - maui
Whenever I navigate to a page via Shell.Current.GoToAsync("Page"); the cross platform event "Appearing" is getting triggered in "Page". The " ...
Read more >
Shell.Current.GoToAsync to xct:Popup restuls with error ...
The Popup view is not type of Page , it cannot be used in the navigation method. To show the popup, try using...
Read more >
Xamarin.Forms Shell navigation
This article shows how to implement low-level multi-touch finger tracking, and how to generate events that signal touch activity. The Shell ...
Read more >
Event windows pop up bug? : r/totalwarhammer
I was playing as chaos dwarf. And I notice that whenever an event is triggered (new technology, faction destroyed, etc), it shows up...
Read more >
AutoPlay does not pop up when CD or DVD is inserted in ...
This article provides information about how to resolve issue with AutoPlay does not pop up when a CD or DVD is inserted into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found