Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Navigation] In wasm doesnt work _navigator.ShowMessageDialogAsync #2275

Closed
2 of 16 tasks
brunodamaso opened this issue May 1, 2024 · 4 comments · Fixed by #2299
Closed
2 of 16 tasks

[Navigation] In wasm doesnt work _navigator.ShowMessageDialogAsync #2275

brunodamaso opened this issue May 1, 2024 · 4 comments · Fixed by #2299
Assignees
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification.

Comments

@brunodamaso
Copy link

brunodamaso commented May 1, 2024

Current behavior

in wasm doesnt work _navigator.ShowMessageDialogAsync,

Expected behavior

Open a dialog message

How to reproduce it (as minimally and precisely as possible)

create an aplication with uno template wizard v.5.2.46 (latest) with the following characteristics
image

in MainViewModel.cs change this:
private async Task GoToSecondView()
{
await _navigator.ShowMessageDialogAsync(this, title: "titulo", content: "content");
//await _navigator.NavigateViewModelAsync(this, data: new Entity(Name!));
}
compile and run in winAppSDK and OK, compile and run in webassembly doesnt show dialog message, and the button keep blocked

Environment

Nuget Package (s):

CSharpMarkup;
Hosting;
Toolkit;
Mvvm;
Navigation;

Package Version(s):
"Uno.Sdk": "5.2.108"

Affected platform(s):

  • iOS
  • macOS (AppKit)
  • Mac Catalyst
  • Android
  • WebAssembly
  • Windows
  • Skia (WPF)
  • Skia (GTK on Linux/macOS/Windows)
  • Skia (Linux Framebuffer)
  • Build tasks

Visual Studio:

  • 2019 (version: )
  • 2022 (version: ) 17.9.6
  • Visual Studio Code (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )

Relevant plugins:
none

  • Resharper (version: )

@brunodamaso brunodamaso added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels May 1, 2024
@nickrandolph
Copy link
Contributor

@brunodamaso thanks for reporting this. We'll investigate this and reply when we know more

@nickrandolph nickrandolph changed the title In wasm doesnt work _navigator.ShowMessageDialogAsync [Navigation] In wasm doesnt work _navigator.ShowMessageDialogAsync May 7, 2024
@HakanL
Copy link

HakanL commented May 10, 2024

I have the same issue in Skia, the button gets disabled and no Message Dialog is shown. Here's a repo: https://github.com/HakanL/Uno.MessageDlg

In my full (private) solution I catch this exception when I'm trying to display the message dialog. I'm not 100% sure it's related as I don't see it in the above repo, but it may be that there isn't a handler for it (unhandled tasks):

Unhandled Task exception: One or more errors occurred. (Trying to set position of the dialog before it is associated with a visual tree. Make sure to use InitializeWithWindow before calling ShowAsync.)
System.AggregateException: One or more errors occurred. (Trying to set position of the dialog before it is associated with a visual tree. Make sure to use InitializeWithWindow before calling ShowAsync.)
 ---> System.InvalidOperationException: Trying to set position of the dialog before it is associated with a visual tree. Make sure to use InitializeWithWindow before calling ShowAsync.
   at Microsoft.UI.Xaml.Controls.ContentDialog.SizeAndPositionContentInPopup() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/ContentDialog/ContentDialog.Visuals.cs:line 220
   at Microsoft.UI.Xaml.Controls.ContentDialog.PrepareContent() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/ContentDialog/ContentDialog.Visuals.cs:line 192
   at Microsoft.UI.Xaml.Controls.ContentDialog.OnApplyTemplate() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/ContentDialog/ContentDialog.cs:line 243
   at Microsoft.UI.Xaml.Controls.Control.TryCallOnApplyTemplate() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Control/Control.cs:line 320
   at Microsoft.UI.Xaml.Controls.Control.ApplyTemplate() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Control/Control.cs:line 484
   at Microsoft.UI.Xaml.Controls.Control.EnsureTemplate() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Control/Control.cs:line 495
   at Microsoft.UI.Xaml.Controls.ContentDialog.<ShowAsync>b__32_0(CancellationToken ct) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/ContentDialog/ContentDialog.cs:line 312
   at Windows.Foundation.AsyncOperation`1.BuildTaskAsync(FuncAsync`2 taskBuilder) in /__w/1/s/src/Uno.Foundation/Internal/AsyncOperation.TResult.cs:line 70
   at System.WindowsRuntimeSystemExtensions.AsTaskCore[TResult](IAsyncOperation`1 source, CancellationToken ct) in /__w/1/s/src/Uno.UWP/System.Runtime/WindowsRuntimeSystemExtensions.cs:line 66
   at Uno.UI.WinRT.Extensions.UI.Popups.MessageDialogContentDialog.ShowAsync(CancellationToken ct) in /__w/1/s/src/Uno.UI/WinRT/Extensions/UI/Popups/MessageDialogContentDialog.cs:line 69
   at Uno.UI.WinRT.Extensions.UI.Popups.MessageDialogExtension.ShowAsync(CancellationToken ct) in /__w/1/s/src/Uno.UI/WinRT/Extensions/UI/Popups/MessageDialogExtension.cs:line 30
   at Windows.UI.Popups.MessageDialog.ShowInnerAsync(CancellationToken ct) in /__w/1/s/src/Uno.UWP/UI/Popups/MessageDialog.cs:line 123
   at Windows.UI.Popups.MessageDialog.<ShowAsync>b__6_0(CancellationToken ct) in /__w/1/s/src/Uno.UWP/UI/Popups/MessageDialog.cs:line 60
   at Windows.Foundation.AsyncOperation`1.BuildTaskAsync(FuncAsync`2 taskBuilder) in /__w/1/s/src/Uno.Foundation/Internal/AsyncOperation.TResult.cs:line 70
   at System.WindowsRuntimeSystemExtensions.AsTaskCore[TResult](IAsyncOperation`1 source, CancellationToken ct) in /__w/1/s/src/Uno.UWP/System.Runtime/WindowsRuntimeSystemExtensions.cs:line 66
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Uno.Extensions.Navigation.Navigators.MessageDialogNavigator.<>c__DisplayClass3_0.<DisplayDialog>b__1(Task`1 result)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)

@HakanL
Copy link

HakanL commented May 10, 2024

Also found this in the documentation, that InitializeWithWindow has to be called, but I'm not sure how to call this since I'm just using the INavigator interface: https://platform.uno/docs/articles/features/dialogs.html

@HakanL
Copy link

HakanL commented May 10, 2024

It seems we're calling InitializeWithWindow, but only for WinUI:

WinRT.Interop.InitializeWithWindow.Initialize(md, hwnd);

Sorry for all the comments, but I just noticed the issue with the message dialogs. I had already upgraded to Uno 5.2, of course I can downgrade, but hoping for a quick fix instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants