I have a program that displays an NSSavePanel as a sheet. Mostly it works. However, it can get into a bad state after I display an ordinary window as a sheet. In that bad state, the code that normally displays the NSSavePanel instead just beeps. I can put a breakpoint on NSBeep and confirm that NSBeep is being called, but there is nothing useful in the stack trace (running on macOS 11.5.2) to suggest what the problem might be. No error message is printed in the debug log.
I might guess that when I displayed the window as a sheet the sheet was not fully cleaned up, but I can show the window as a sheet any number of times without any obvious problem.
I found the answer. When I displayed the ordinary window as a sheet, I failed to call
endSheet:. I only closed the window. Odd that many things are insensitive to this error. Even displaying an NSOpenPanel worked, but not NSSavePanel. I suppose the beep might be related to some event delivered to the owner window while it was "busy".