Calling NSAlert.layout() on macOS 10.12 triggers DETECTED_MISSING_CONSTRAINTS

Originator:rsfinn
Number:rdar://28700495 Date Originated:2016-10-10
Status:Duplicate/20880211 (Open) Resolved:
Product:macOS 10.12 Sierra Product Version:16A323
Classification:Other Bug Reproducible:Always
 
Summary:
The documentation for NSAlert.layout() suggests that it can be called to force an NSAlert to be laid out before being displayed. Under macOS 10.12, doing so causes the internal function DETECTED_MISSING_CONSTRAINTS to display a warning message on the console.  There is no obvious way to avoid having this happen; the actions suggested by the warning message do not apply in this case.

Steps to Reproduce:
1) Call NSAlert.layout() in an application linked against the 10.11 SDK.
2) Run the application under macOS 10.12.
3) Cause the alert to be displayed.

Expected Results:
The alert is displayed without a warning message being written to the console.

Actual Results:
The alert is displayed normally, but a warning message that references DETECTED_MISSING_CONSTRAINTS is written to the console.

Notes:
There does not appear to be a supported way to force NSAlert to add the necessary missing constraints.  I tried iterating the subviews of the alert's content view and setting translatesAutoresizingMaskIntoConstraints to true, but that did not appear to have any useful effect.

My use case for NSAlert.layout() is to get the final window size when the message and informative texts are unusually long, in order to position the window relative to the application's main window before running it as a modal dialog.  (This application is being ported from another platform; normally I would run the alert as a sheet, but in this workflow it makes more sense to center the alert over the main area of the window, leaving the content at the four edges of the window visible.)

Comments

Update for 10.12.2

This issue is still present in macOS 10.12.2 (16C67).

Also having this issue

I am also having this issue without calling NSAlert.layout(). This code halts on myPopup.runModal().

func happyAlert(message: String, info: String) { let myPopup: NSAlert = NSAlert() myPopup.messageText = message myPopup.informativeText = info myPopup.alertStyle = NSAlertStyle.informational myPopup.addButton(withTitle: "OK") myPopup.runModal() }

The whole story is here: http://stackoverflow.com/questions/40404846/new-auto-layout-errors-with-xcode-8-1

By arbourmedia at Nov. 3, 2016, 3:17 p.m. (reply...)

Update for 10.12.1

This issue is still present in macOS 10.12.1 (16B2555).


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!