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

DisplayAlert not working on MacCatalyst and UWP #11766

Closed
YiannisBourkelis opened this issue Nov 30, 2022 · 12 comments
Closed

DisplayAlert not working on MacCatalyst and UWP #11766

YiannisBourkelis opened this issue Nov 30, 2022 · 12 comments
Labels
area-controls-dialogalert DisplayAlert, dialog platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Milestone

Comments

@YiannisBourkelis
Copy link

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

@YiannisBourkelis YiannisBourkelis added the t/bug Something isn't working label Nov 30, 2022
@PureWeen
Copy link
Member

@YiannisBourkelis Can you paste your exception here so we can see it?

@PureWeen PureWeen added this to the Backlog milestone Nov 30, 2022
@ghost
Copy link

ghost commented Nov 30, 2022

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 PureWeen added the area-controls-dialogalert DisplayAlert, dialog label Nov 30, 2022
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Nov 30, 2022
@YiannisBourkelis
Copy link
Author

@PureWeen yes, I had to start the app without debugging and attach the debugger when the exception is raised. This is what i have:

Unhandled exception at 0x00007FF9E215FDF2 (KernelBase.dll) in DisplayAlertIssue.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x00000294655FF1D0, 0x0000000000000001).

@drasticactions
Copy link
Contributor

I think the root of the problem is how you're using DisplayAlert.

https://github.com/YiannisBourkelis/maui_issues/blob/main/src/DiplayAlertIssue/DisplayAlertIssue/App.xaml.cs#L12-L28

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.

@YiannisBourkelis
Copy link
Author

@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.

@YiannisBourkelis
Copy link
Author

I pushed the changes on the reproduction project

@Mat3oo
Copy link

Mat3oo commented Jan 6, 2023

Hi,

I've also experienced DisplayAlert (as a note DisplayPromptAsync hasn't got this issue) not rendering correctly on MacCatalyst , while other tested platforms (Windows, Android, iOS, iPad) worked fine.
What I was able to find out is that, displaying message with more than 17 lines, causes the alert modal to be rendered as thin line on the screen.
Here is example code (I'm not sure if on all screens it will be rendered as 17 new lines, if not, for-loop counter should be adjusted):

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.

@pvoelker
Copy link

@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...

@pvoelker
Copy link

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...

@Zhanglirong-Winnie Zhanglirong-Winnie added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Aug 18, 2023
@ghost
Copy link

ghost commented Aug 18, 2023

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.

@Zhanglirong-Winnie
Copy link
Collaborator

Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0(.NET8). Not repro on macOS and windows platform with sample project.
https://github.com/YiannisBourkelis/maui_issues/tree/main/src/DiplayAlertIssue/DisplayAlertIssue

@pvoelker
Copy link

pvoelker commented Aug 18, 2023

Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0(.NET8). Not repro on macOS and windows platform with sample project. https://github.com/YiannisBourkelis/maui_issues/tree/main/src/DiplayAlertIssue/DisplayAlertIssue

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...

@ghost ghost closed this as completed Aug 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 25, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-dialogalert DisplayAlert, dialog platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants