Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

[Bug] RootViewController error when resetting navigation stack to a page with xct:StatusBarEffect.Color from a PopupPage on iOS #269

Open
maxchu92 opened this issue May 13, 2022 · 0 comments

Comments

@maxchu92
Copy link

maxchu92 commented May 13, 2022

Description

An error of RootViewController will occur on iOS when resetting the navigation stack with a page that has xct:StatusBarEffect.Color using _navigationService.NavigateAsync("/NavigationPage/MainPage"); from a PopupPage. I had reproduced this issue in both environment, Xamarin.Forms independently, and Xamarin.Forms + Prism.Forms. By changing the Application.Current.MainPage in a PopupPage, it will occur as well. This error will occur if I am trying to reset the navigation stack to a page with xct:StatusBarEffect.Color.

Apparently, if the navigation stack is reset using Application.Current.MainPage = new NavigationPage(new MainPage()), before PopupNavigation.Instance.PopAllAsync() is called in a Xamarin.Forms independent environment, this error will not occur. Maybe the sequence of of navigation need to be rearranged in Prism.Plugin.Popups?

Exception

System.NullReferenceException: 'RootViewController'

Stack Trace

  at Xamarin.CommunityToolkit.iOS.Effects.PlatformStatusBarEffect.UpdateStatusBarAppearance (UIKit.UIWindow window) [0x00010] in <b86a3dcb5c1f42eeafd9e295123844ec>:0 
  at Xamarin.CommunityToolkit.iOS.Effects.PlatformStatusBarEffect.SetColor (Xamarin.Forms.Color color) [0x00079] in <b86a3dcb5c1f42eeafd9e295123844ec>:0 
  at Xamarin.CommunityToolkit.iOS.Effects.PlatformStatusBarEffect.OnAttached () [0x0000b] in <b86a3dcb5c1f42eeafd9e295123844ec>:0 
  at Xamarin.Forms.Effect.SendAttached () [0x00009] in D:\a\_work\1\s\Xamarin.Forms.Core\Effect.cs:54 
  at Xamarin.Forms.RoutingEffect.SendAttached () [0x00000] in D:\a\_work\1\s\Xamarin.Forms.Core\RoutingEffect.cs:29 
  at Xamarin.Forms.Element.AttachEffect (Xamarin.Forms.Effect effect) [0x00045] in D:\a\_work\1\s\Xamarin.Forms.Core\Element.cs:513 
  at Xamarin.Forms.Element.set_EffectControlProvider (Xamarin.Forms.IEffectControlProvider value) [0x0007c] in D:\a\_work\1\s\Xamarin.Forms.Core\Element.cs:238 
  at Xamarin.Forms.Platform.iOS.EffectUtilities.RegisterEffectControlProvider (Xamarin.Forms.IEffectControlProvider self, Xamarin.Forms.IElementController oldElement, Xamarin.Forms.IElementController newElement) [0x0001a] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\EffectUtilities.cs:20 
  at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00094] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:141 
  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240 
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00008] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:378 
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x0001d] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:353 
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.<ViewDidLoad>b__47_0 (Xamarin.Forms.Page p) [0x00024] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:239 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 
  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSAction.cs:178 
--- End of stack trace from previous location where exception was thrown ---

  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/UIKit/UIApplication.cs:85 
  at BugTest2.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\DT005\source\repos\BugTest2\BugTest2\BugTest2.iOS\Main.cs:14 

Link to Reproduction Sample

  1. Xamarin.Forms Version

  2. Xamarin.Forms + Prism.Forms Version

Steps to Reproduce

  1. Run the app.
  2. Click on "Open Popup Page"
  3. Click on "Reset Stack" OR "Back to Root using Command"

Expected Behavior

Navigation stack is reset and go to MainPage without any error.

Actual Behavior

Error occurs when stack is reset.

Basic Information

  • Version with issue:

    • Xamarin.Forms v5.0.0.2401
    • Xamarin.CommunityToolkit v2.0.2
    • Rg.Plugin.Popup v2.1.0
    • Prism.DryIoc.Forms v8.1.97
    • Prism.Plugin.Popups v8.0.76
  • Last known good version:

  • IDE:

    • Visual Studio 2022
  • Platform Target Frameworks:

    • iOS: 15.4
  • Nuget Packages:

    • Xamarin.Essentials v1.7.3
    • Xamarin.Essentials.Interfaces v1.7.3

I had already create a bug report in XamarinCommunityToolkit repository and Rg.Plugins.Popup repository as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant