UIAlertController with many lines fails on macOS Ventura (Catalyst)

Hi all

When running the following code on macOS Ventura, I get the error below: (At least in a Catalyst app running on macOS.)

Code to reproduce:

NSString *message = @"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20";

UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert" message:message preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}];
[alert addAction:yesAction];

UIAlertAction* noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {}];
[alert addAction:noAction];

[self presentViewController:alert animated:YES completion:nil];

Error:

[Layout] Unable to simultaneously satisfy constraints:

(
    "<NSLayoutConstraint:0x60000265caa0 _NSAlertContentView:0x7fc0600390a0.trailingMargin == NSTextField:0x7fc06003a900.trailing   (active)>",
    "<NSLayoutConstraint:0x60000265c9b0 _NSAlertImageView:0x7fc06003a460.leading == _NSAlertContentView:0x7fc0600390a0.leadingMargin   (active)>",
    "<NSLayoutConstraint:0x60000265ca50 H:[_NSAlertImageView:0x7fc06003a460]-(10)-[NSTextField:0x7fc06003a900]   (active)>",

    "<NSLayoutConstraint:0x60000265ca00 _NSAlertImageView:0x7fc06003a460.width == 64   (active)>"

)

Will attempt to recover by breaking constraint 

<NSLayoutConstraint:0x60000265ca50 H:[_NSAlertImageView:0x7fc06003a460]-(10)-[NSTextField:0x7fc06003a900]   (active)>

It looks like the error happens as soon as the message is displayed with scrollbar on older macOS versions.

Sorry not to help, there may be an internal limit to alerts. Usually, alerts are not done to display 20 lines of text.

Try it with 19 lines, then 18, then 17 etc. When you hit a number of lines where the error doesn't appear, you'll know that alerts can only have that number of lines.

I really wouldn't have an alert with that many lines in; I'd display a modal view instead with all the text on it, and a couple of buttons at the bottom.

This is an issue only on macOS Ventura. It works fine on iOS and older macOS, but freezes the app on macOS Ventura.

It seems to be not only with many lines, but also with a long message. See here: https://stackoverflow.com/questions/74256830/multi-line-uialertcontroller-freezes-on-macos-ventura

In the mean time I also opened an Apple DTS ticket with my sample code above and the engineer confirmed that this is an Apple bug an I should file bug report.

In the mean time I also opened an Apple DTS ticket with my sample code above and thy confirmed that it is an Apple bug and I should file a bug report.

BTW: It seems to be also an issue with a long message and not only with a message containing many \n. --> https://stackoverflow.com/questions/74256830/multi-line-uialertcontroller-freezes-on-macos-ventura

UIAlertController with many lines fails on macOS Ventura (Catalyst)
 
 
Q