The Shape of Everything
A website mostly about Mac stuff, written by August "Gus" Mueller
» Acorn
» Retrobatch
» Mastodon
» Micro.blog
» Instagram
» Github
» Maybe Pizza?
» Archives
» Feed
» Micro feed
March 23, 2018

This is just a quick note to point out, because I wasn't aware or I had previously forgotten, that Quick Look plugins on MacOS are multithreaded by default. This can be turned off however, by setting the property list key QLNeedsToBeRunInMainThread to YES.

A couple of days ago I was sent an Acorn crash report by my fellow dev Daniel Jalkut, which showed a crash in a background thread, from Acorn's Quick Look plugin, when trying to use the File ▸ Open… window. Two things stood out to me at once.

1) Huh, those are multithreaded now?
2) Why is this running in Acorn's address space?

Apparently QL plugins have always been multithreaded, and it's just been pure luck that the crash wasn't happening more often. Well, mostly luck. The crash would only occur when the plugin was rendering two or more Acorn images made from version 1.x, and those images had text layers in them. There aren't many of those images sitting around on people's computers. (The crash was caused by using a shared NSLayout manager on two different threads at once. I've got it fixed for the next Acorn update).

The other surprising thing was that Acorn was crashing at all. I had always assumed that the plugins ran in their own address space? Apparently not always. So if you write a bad Quick Look plugin, you can bring down your own app, (and possibly even someone else's?).

Lesson learned, I now know better, better stronger faster, etc.