dotnet/maui · error · NotSupportedException

ParentingViewController parent could not be found. Please fi

Error message

ParentingViewController parent could not be found. Please file a bug.

What it means

Thrown during OnPushViewAsync on the iOS NavigationPage renderer when the pushed page's ViewController cannot find a ParentingViewController as its parent. The code first guards against renderer/ViewController being null (a rapid push/pop teardown fix referencing ShellSectionRenderer #32426), but if they exist and ParentViewController is not a ParentingViewController, this NotSupportedException fires. It indicates the view controller hierarchy is in an unexpected state during a push.

Source

Thrown at src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs:510

		{
			CompletePendingNavigation(false);

			_pendingNavigationRequest = new TaskCompletionSource<bool>();

			_ = page.ToPlatform(MauiContext);
			var renderer = (IPlatformViewHandler)page.Handler;
			// renderer or ViewController can be null if a rapid push/pop causes the handler
			// to be torn down before this navigation completes (mirrors fix for ShellSectionRenderer #32426)
			if (renderer?.ViewController == null)
			{
				var pendingTask = _pendingNavigationRequest.Task;
				CompletePendingNavigation(false);
				return pendingTask;
			}

			var parentViewController = renderer.ViewController.ParentViewController as ParentingViewController;
			if (parentViewController == null)
				throw new NotSupportedException("ParentingViewController parent could not be found. Please file a bug.");

			EventHandler appearing = null, disappearing = null;
			appearing = (s, e) =>
			{
				CompletePendingNavigation(true);
			};

			disappearing = (s, e) =>
			{
				CompletePendingNavigation(false);
			};

			if (NavigationDelegate is not null)
				NavigationDelegate.WaitingForNavigationToFinish = true;

			_removeLifecycleEvents = new ActionDisposable(() =>
			{
				// This ensures that we don't cause multiple calls to CompletePendingNavigation.

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Avoid rapid interleaved push/pop calls — chain navigation with await and a navigation guard lock.
  2. If the error references the rapid teardown path (renderer non-null but parent wrong), ensure the page is not being reused across NavigationPage instances.
  3. Debounce or queue navigation operations so only one push/pop is in-flight at a time.
  4. Check for event handler or lifecycle callback that triggers navigation during page teardown (e.g., OnDisappearing calling PushAsync).
  5. If reproducible under normal usage, file a bug with the specific navigation sequence and device/OS version.

Example fix

// before
async Task NavigateAround()
{
    await Navigation.PushAsync(new PageA());
    await Navigation.PopAsync();
    await Navigation.PushAsync(new PageB()); // may race with teardown
}

// after
private readonly SemaphoreSlim _navLock = new(1, 1);
async Task NavigateAround()
{
    await _navLock.WaitAsync();
    try
    {
        await Navigation.PushAsync(new PageA());
        await Navigation.PopAsync();
        await Navigation.PushAsync(new PageB());
    }
    finally { _navLock.Release(); }
}
Defensive patterns

Strategy: validation

Validate before calling

// Serialize navigation operations with a semaphore
private readonly SemaphoreSlim _navLock = new(1, 1);
async Task SafePushAsync(Page page)
{
    await _navLock.WaitAsync();
    try { await Navigation.PushAsync(page); }
    finally { _navLock.Release(); }
}

Try / catch

try { await Navigation.PushAsync(page); }
catch (NotSupportedException ex) when (ex.Message.Contains("ParentingViewController parent could not be found"))
{
    // Handler teardown race — retry once after a short delay or abort gracefully

Prevention

When it happens

Trigger: Triggered when `renderer.ViewController.ParentViewController as ParentingViewController` returns null during a push. This happens when: (1) a rapid push/pop sequence tears down the handler mid-navigation but the renderer/ViewController survive (partial teardown); (2) the page's view controller was added to a non-NavigationPage container; (3) the page was already pushed to a different NavigationPage instance. The code attempts to handle pending navigation if renderer is null, but if renderer exists with a wrong parent type it throws.

Common situations: 1) Fast programmatic navigation (multiple PushAsync then PopAsync in quick succession) where the handler is being disconnected while a push is still resolving. 2) Page shared or moved between multiple NavigationPage instances. 3) Custom navigation patterns that reparent view controllers. 4) Suspend/resume during navigation causing the platform hierarchy to be rebuilt. 5) Shell-to-NavigationPage interop edge cases.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/d7e8412b05bff243. Report an issue: GitHub.