uno.extensions icon indicating copy to clipboard operation
uno.extensions copied to clipboard

Fix navigation race condition with NavigateForResult

Open Copilot opened this issue 4 months ago • 3 comments

GitHub Issue (If applicable): closes https://github.com/unoplatform/uno.extensions/issues/2905

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

When navigating from Page A to Page B with NavigateViewModelForResultAsync, if the user triggers back navigation (via NavigationBar MainCommand or hardware back button) before Page B's ViewModel finishes loading, the awaited navigation call hangs forever. The ResponseNavigator's TaskCompletionSource never completes because back navigation through Frame_Navigated event bypasses the ResponseNavigator.NavigateAsync flow.

What is the new behavior?

Back navigation now correctly completes pending ResponseNavigator instances regardless of how the navigation is triggered. The FrameNavigator.NavigatedBackAsync method checks for any pending ResponseNavigator in the service provider and completes it before restoring the previous navigator.

Changes:

  • IResponseNavigator: Added CompleteWithResult(object?) method
  • ResponseNavigator<TResult>: Implemented CompleteWithResult as an explicit interface implementation to fix TypeLoadException when the internal interface is used across assembly boundaries. Added private CompleteWithResultCore method with early-exit check for thread safety.
  • FrameNavigator.NavigatedBackAsync: Detects and completes pending ResponseNavigator on back navigation

PR Checklist

Please check if your PR fulfills the following requirements:

  • [ ] Tested code with current supported SDKs
  • [ ] Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • [ ] Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • [ ] Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • [x] Contains NO breaking changes
  • [ ] Updated the Release Notes
  • [x] Associated with an issue (GitHub or internal)

Other information

Internal Issue (If applicable):


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Dec 01 '25 21:12 Copilot