-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
DisplayAlert not working on MacCatalyst and UWP #11766
Comments
@YiannisBourkelis Can you paste your exception here so we can see it? |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
@PureWeen yes, I had to start the app without debugging and attach the debugger when the exception is raised. This is what i have:
|
I think the root of the problem is how you're using DisplayAlert. You're calling for it in OnStart. The Application has started, the window nor page has fully loaded yet. The alert can't be displayed because there's nowhere for it to go. If you call it when the window is loaded, it seems to appear fine on both platforms. I'm not sure what the expected behavior should be here. |
@drasticactions I tried other events too. Window.Creared and Window.Activated. The issue remains on both Windows and MacCatalyst. I placed the DisplayAlert code on the button click now to ensure that the page is loaded. The issue remains on MacCatalyst. It displays a line instead of the alert. |
I pushed the changes on the reproduction project |
Hi, I've also experienced StringBuilder messageBuilder = new StringBuilder(string.Empty);
for (int i = 0; i < 341; i++)
{
messageBuilder.Append('W');
}
string message = messageBuilder.ToString();
await Application.Current.MainPage.DisplayAlert("Title", message, "Ok"); 341 counts of 'W' equals to 18 lines, which will result in failed display. 340 or less 'W's result in proper displaying. |
@Mat3oo I see that the problem is related to the length of the string. I am building an 'about' box using DisplayAlert. And it goes weird if the string it is given is too long... |
Ideally it would be great to eliminate the limit. However I wonder if this is a limitation on the MacOS side. If so, a meaningful exception would be good making the character limit clear... |
Hi @YiannisBourkelis. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0(.NET8). Not repro on macOS and windows platform with sample project. |
So one of the issues identified with DisplayAlert is the length of the string. Strings that are over 340 on MacCatalyst (macOS) causes the crash. It looks like the 340 limit is not being exercised (https://github.com/YiannisBourkelis/maui_issues/blob/5e63991b78fdc8ed4bcbec9fcff65f65a7cd0c19/src/DiplayAlertIssue/DisplayAlertIssue/MainPage.xaml.cs#L31). My hunch is this is a limit on the macOS side. If this is the case, a dedicated exception to help the user understand this is a hard limitation on DisplayAlert would be very helpful. Versus a 'general' exception... |
Description
DisplayAlert is working on iOS and Android but I am experiencing some issues on MacCatalyst an Windows.
On Windows, it does not work at all when compiling as UWP app. It raises an unhandled exception.
On MacCatalyst, if the message string is like the one on the attached case, it displays a line at the center of the screen and nothing else.
Steps to Reproduce
Run the reproduction project on MacCatalyst and on Windows (UWP). The Alert will not display.
Link to public reproduction project repository
https://github.com/YiannisBourkelis/maui_issues/tree/main/src/DiplayAlertIssue/DisplayAlertIssue
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Windows, macOS
Affected platform versions
Latest MacCatalyst (Ventura 13.0.1) and Windows 10 Pro 22H2
Did you find any workaround?
No
Relevant log output
No response
The text was updated successfully, but these errors were encountered: