Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,6 @@ protected virtual void OnElementSet(Shell shell)
((IShellController)shell).AddAppearanceObserver(this, shell);

SwitchFragment(FragmentManager, _frameLayout, shell.CurrentItem, false);

var rootManager = _mauiContext.GetNavigationRootManager();
rootManager?.OnWindowContentPlatformViewCreated();
}

IShellItemRenderer _currentView;
Expand Down
5 changes: 5 additions & 0 deletions src/Core/src/Handlers/Window/WindowHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ private protected override void OnDisconnectHandler(object platformView)
void OnRootViewChanged(object? sender, EventArgs e)
{
if (VirtualView.VisualDiagnosticsOverlay != null && _rootManager?.RootView is ViewGroup)
{
if (VirtualView.VisualDiagnosticsOverlay.IsPlatformViewInitialized)
VirtualView.VisualDiagnosticsOverlay.Deinitialize();

VirtualView.VisualDiagnosticsOverlay.Initialize();
}
}

// This is here to try and ensure symmetry with disconnect code between test handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ internal void Connect(IView view, IMauiContext? mauiContext = null)
// this is called after the Window.Content is created by
// the fragment. We can't just create views on demand
// need to let the fragments fall
internal void OnWindowContentPlatformViewCreated()
void OnWindowContentPlatformViewCreated()
{
RootViewChanged?.Invoke(this, EventArgs.Empty);

Expand Down Expand Up @@ -155,6 +155,8 @@ void SetContentView(IView? view)

if (FragmentManager.IsDestroyed(context))
_viewFragment = null;

RootViewChanged?.Invoke(this, EventArgs.Empty);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you validate this with page swapping variations?

If the user swaps the main page for a different shell page
If they swap it for non shell then swap back to a shell page?

The main thing I'm curious about is if the "remove" path is followed if we need to wait for that to finish before calling RootViewChanged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed with 2f4cd0c, as I wrote below it's unrelated to what I was addressing with this PR (you would have hit this in current MAUI stable switching any Window main page.)

The issue is the way the layers work with Android and where the graphics layout is put. When we initialize the VisualDiagnosticsOverlay for Android, it goes on the top most layout of the view, which just so happens to be whatever the current Page content for a given Window is. That is unlike iOS/Mac/Windows where it's put above every MAUI view so it works regardless of switching out the page. With Android we need to recreate the overlay if you swap out the MainPage of a given window, since swapping it takes out the graphics layer.

}
else
{
Expand Down