maui icon indicating copy to clipboard operation
maui copied to clipboard

NavigationView cannot be null with navigation in modal

Open jenscski opened this issue 3 years ago • 1 comments

Description

A crash with the error **System.InvalidOperationException:** 'NavigationView cannot be null'

It worked with latest 6-versjon, but not with 7-rc1

Steps to Reproduce

Create new Maui project Set App.MainPage to new NavigationPage(new MainPage())

In MainPage, open modal (Navigation.PushModalAsync(new NavigationPage(new SomePage()))) Close modal Navigation.PopModalAsync());

And it crashes

Link to public reproduction project repository

https://github.com/jenscski/MauiNavigationViewCannotBeNull

Version with bug

Unknown/Other (please specify)

Last version that worked well

6.0.424

Affected platforms

Android

Affected platform versions

Only tested with Android

Did you find any workaround?

No

Relevant log output

**System.InvalidOperationException:** 'NavigationView cannot be null'

**System.InvalidOperationException:** 'NavigationView cannot be null'

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: NavigationView cannot be null
[mono-rt]    at Microsoft.Maui.Platform.StackNavigationManager.OnNavigationViewFragmentDestroyed(FragmentManager fm, NavigationViewFragment navHostPageFragment) in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs:line 358
[mono-rt]    at Microsoft.Maui.Platform.StackNavigationManager.Callbacks.OnFragmentViewDestroyed(FragmentManager fm, Fragment f) in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs:line 470
[mono-rt]    at AndroidX.Fragment.App.FragmentManager.FragmentLifecycleCallbacks.n_OnFragmentViewDestroyed_Landroidx_fragment_app_FragmentManager_Landroidx_fragment_app_Fragment_(IntPtr jnienv, IntPtr native__this, IntPtr native_fm, IntPtr native_f) in /Users/runner/work/1/s/generated/androidx.fragment.fragment/obj/Release/net6.0-android/generated/src/AndroidX.Fragment.App.FragmentManager.cs:line 806
[mono-rt]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLL_V(_JniMarshal_PPLL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 187

jenscski avatar Sep 21 '22 10:09 jenscski

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Sep 21 '22 18:09 ghost

Cannot reproduce the issue with maui-net7 rc1 image

issue-10235 Also tested on current net7 branch and the issue seems to be fixed.

jsuarezruiz avatar Sep 23 '22 08:09 jsuarezruiz

Tested again, on two units, one with Android 11.0, and one with 7.1

Did a clean checkout of my example before testing, just in case.

Both crashes with same error as before

**System.InvalidOperationException:** 'NavigationView cannot be null'

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: NavigationView cannot be null
[mono-rt]    at Microsoft.Maui.Platform.StackNavigationManager.OnNavigationViewFragmentDestroyed(FragmentManager fm, NavigationViewFragment navHostPageFragment) in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs:line 358
[mono-rt]    at Microsoft.Maui.Platform.StackNavigationManager.Callbacks.OnFragmentViewDestroyed(FragmentManager fm, Fragment f) in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs:line 470
[mono-rt]    at AndroidX.Fragment.App.FragmentManager.FragmentLifecycleCallbacks.n_OnFragmentViewDestroyed_Landroidx_fragment_app_FragmentManager_Landroidx_fragment_app_Fragment_(IntPtr jnienv, IntPtr native__this, IntPtr native_fm, IntPtr native_f) in /Users/runner/work/1/s/generated/androidx.fragment.fragment/obj/Release/net6.0-android/generated/src/AndroidX.Fragment.App.FragmentManager.cs:line 806
[mono-rt]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLL_V(_JniMarshal_PPLL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 187

Microsoft Visual Studio Professional 2022
Version 17.4.0 Preview 2.1
VisualStudio.17.Preview/17.4.0-pre.2.1+32916.344
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Professional

ASP.NET and Web Tools   17.4.210.756
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.4.210.756
Azure App Service Tools v3.0.0

C# Tools   4.4.0-2.22430.14+2f760738cb92f32f50c981b68ba04ac3c8b7ee48
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.4.1 (main@2ee106a)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.4.19 (8c0a575)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core)   17.0.0.2243101+64a0117763b8eb085c75bdb80329e16e5a2c65a5
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.0.62207.28050
Microsoft SQL Server Data Tools

TypeScript Tools   17.0.10901.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.4.0-2.22430.14+2f760738cb92f32f50c981b68ba04ac3c8b7ee48
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.4.0-beta.22429.6+22514929f2e903ea8c14947bea7c2b242886e1ee
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSPackage Extension   1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin   17.4.0.171 (d17-4-net7@4d0f4c0)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.4.0.124 (remotes/origin/d17-4@ffbba0c031)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   13.0.99.81 (main/7c9c24b)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: dffa5ab
    Java.Interop: xamarin/java.interop/main@2c8b0a8f
    SQLite: xamarin/sqlite/3.39.2@40e8743
    Xamarin.Android Tools: xamarin/xamarin-android-tools/main@29f11f2

c:\Temp\MauiNavigationViewCannotBeNull>dotnet --info
.NET SDK:
 Version:   7.0.100-rc.1.22431.12
 Commit:    f1cf61e1c0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12\

Host:
  Version:      7.0.0-rc.1.22426.10
  Architecture: x64
  Commit:       06aceb7015

.NET SDKs installed:
  3.1.423 [C:\Program Files\dotnet\sdk]
  5.0.214 [C:\Program Files\dotnet\sdk]
  6.0.109 [C:\Program Files\dotnet\sdk]
  6.0.401 [C:\Program Files\dotnet\sdk]
  7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  arm64 [C:\Program Files\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation]
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
c:\Temp\MauiNavigationViewCannotBeNull>dotnet workload list

Installed Workload Id      Manifest Version                  Installation Source
--------------------------------------------------------------------------------
runtimes-windows           7.0.0-rc.1.22426.10/7.0.100       VS 17.4.32916.344
maui-windows               7.0.0-rc.1.6683/7.0.100-rc.1      VS 17.4.32916.344
maui-maccatalyst           7.0.0-rc.1.6683/7.0.100-rc.1      VS 17.4.32916.344
maccatalyst                15.4.1029-rc.1/7.0.100-rc.1       VS 17.4.32916.344
maui-ios                   7.0.0-rc.1.6683/7.0.100-rc.1      VS 17.4.32916.344
ios                        15.4.1029-rc.1/7.0.100-rc.1       VS 17.4.32916.344
maui-android               7.0.0-rc.1.6683/7.0.100-rc.1      VS 17.4.32916.344
android                    33.0.0-rc.1.151/7.0.100-rc.1      VS 17.4.32916.344

Use `dotnet workload search` to find additional workloads to install.

jenscski avatar Sep 23 '22 08:09 jenscski

The issue will be fixed by https://github.com/dotnet/maui/pull/10353

jsuarezruiz avatar Sep 29 '22 12:09 jsuarezruiz