Quick Look Preview Extension -viewWill/DidDisappear not called when expected

Number:rdar://FB9964402 Date Originated:2022-03-22
Status:Open Resolved:
Product:Quick Look Framework Product Version:
Classification: Reproducible:
I’m trying to write a preview extension that will preview custom audio files.
These audio files are played using AVAudioEngine, and it’s important to be able to stop playback after the user switches to another file using the arrow keys while Quick Looking in Finder.

Currently, the preview extension’s NSViewController does not get a -viewWill/DidDisappear message when you Quick Look through Finder and go to the next file using the arrow keys.

If you skip multiple files (using the arrow keys), the NSViewController eventually does receive -viewWill/DidDisappear, but not receiving these messages immediately when the user goes to the next file makes implementing a custom preview extension for audio content impossible, since the audio keeps playing while the user is Quick Looking the next file.

1. Create a macOS app
2. Add a Quick Look Preview Extension target
3. Associate any custom file type to the preview extension
4. Implement logging in -viewWillDisappear and -viewDidDisappear
5. Run the extension target in the Quick Look Preview Simulator
5. Preview any associated files in Finder, and go up/down between files using the arrow keys.

Expected: That -viewWill/DidDisappear (or any other appropriate callbacks) are called when the NSViewController is no longer visible.

Actual: -viewWill/DidDisappear are not called, the first time you switch files. It’s cached for at least two files before being called, and subsequently deallocated.

PS. This also means that -viewWill/DidAppear is not called correctly when returning to a previously previewed file, unless the user have skipped enough files for the NSViewController to have been deallocated (in which case a new view controller is created).


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!