Windows are not promptly dealloc'ed with TouchBar in specific circumstances

Originator:peter
Number:rdar://29590973 Date Originated:09-Dec-2016 01:54 PM
Status:Open Resolved:
Product:macOS + SDK Product Version:10.12.1 / TouchBar
Classification:Usability Reproducible:Always
 
Summary:
On TouchBar Macs (or Macs running TouchBar Server), if an application has a key window, and it is closed while the application is in the background, the window is not dealloc'ed until a new key window is created in the application.

Steps to Reproduce:
Run the attached application on a TouchBar MacBook (or on a Mac running TouchBar Server).  Click the button.  The Mac will switch to the Finder, and the window will close one second later.  But the NSPanel will not be dealloced.  Switch back to the application and open the About box and only then is the NSPanel dealloced.  The consequence of this is that cleanup done in dealloc will be arbitrarily delayed which can have negative user visible consequences.

If the window is not "key", then the bug does not happen.

If the window/app is in the foreground when it closes, then the bug does not happen.

The bug will happen if you simply close a window in the background by clicking on the red close icon, so it potentially affects *all* applications with unpredictable consequences.

Expected Results:
When the window is closed, it should be dealloced promptly regardless of the circumstanced.

Actual Results:
dealloc is deferred arbitrarily (perhaps forever).  This could lead to data loss (if saving user data is not done until the window dealloc for example) or other resource wastage, including battery drain consequences or other issues that might arise when an expected deallocation does not happen until a later window creation.

Version:
10.12.1 (16B2657)

Notes:
TouchBar server (https://github.com/zydeco/TouchBarServer) duplicates causing this issue which makes testing it easier, but it happens specifically on the TouchBar MacBook Pro.

Configuration:


Attachments:
'TestWindowCloseDeallocation.zip' was successfully uploaded.

The attachment simply shows when the dealloc happen, but it should apply to any key window closed in the background.

Comments


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!