Apple Mail crashes on launch if connection logging is enabled

This was a fun one.  Mail started crashing on launch for absolutely no apparent reason – nothing had changed to its config or similar in a long time.  The crash logs were all fingering an identical culprit – -[IMAPTaskManager secondaryIdleMailboxName] called on the wrong GCD queue:

Process: Mail [19884]
Path: /Applications/Mail.app/Contents/MacOS/Mail
Identifier: com.apple.mail
Version: 11.3 (3445.6.18)
Build Info: Mail-3445006018000000~4
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Mail [19884]
User ID: …

Date/Time: 2018-04-19 16:44:45.717 -0700
OS Version: Mac OS X 10.13.4 (17E199)
Report Version: 12
Anonymous UUID: …

Sleep/Wake UUID: …

Time Awake Since Boot: 94000 seconds
Time Since Wake: 530 seconds

System Integrity Protection: enabled

Crashed Thread: 13 Dispatch queue: Task Manager Serialization Queue (QOS: UNSPECIFIED)

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This method should only be called on the serialization queue'
terminating with uncaught exception of type NSException
abort() called

Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff55da96bb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff7d4c1942 objc_exception_throw + 48
2 CoreFoundation 0x00007fff55daf2a2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff57ee7340 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 IMAP 0x00007fff6fe88959 -[IMAPTaskManager secondaryIdleMailboxName] + 216
5 IMAP 0x00007fff6fe880cb -[IMAPTask mailboxIsUserVisibleUsingDataSource:] + 180
6 IMAP 0x00007fff6fe6ab68 -[IMAPMailboxSyncTask _nextNetworkPriorityAndOperation:reservedNetworkPriority:] + 164
7 IMAP 0x00007fff6fe6c4ba -[IMAPMailboxSyncTask recalculatePriorities] + 398
8 IMAP 0x00007fff6fe67dd9 -[IMAPMailboxSyncTask initWithDataSource:taskManager:imapMailbox:fromStatus:forceFullSync:] + 766
9 IMAP 0x00007fff6fe931f7 -[IMAPTaskManager _syncMailboxWithDataSource:withIMAPMailbox:fromStatus:forceFullSync:userInitiated:] + 370
10 IMAP 0x00007fff6fe92e68 -[IMAPTaskManager syncMailboxWithDataSource:withIMAPMailbox:fromStatus:forceFullSync:userInitiated:] + 240
11 IMAP 0x00007fff6fe9631a -[IMAPTaskManager didAddMessagesWithUnknownUID:toDataSource:] + 872
12 Foundation 0x00007fff57e4a5df __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
13 Foundation 0x00007fff57e4a441 -[NSBlockOperation main] + 68
14 Foundation 0x00007fff57e488ee -[__NSOperationInternal _start:] + 778
15 Foundation 0x00007fff57e44917 __NSOQSchedule_f + 369
16 libdispatch.dylib 0x00007fff7e09ee08 _dispatch_client_callout + 8
17 libdispatch.dylib 0x00007fff7e0b1ed1 _dispatch_continuation_pop + 472
18 libdispatch.dylib 0x00007fff7e0a9783 _dispatch_async_redirect_invoke + 703
19 libdispatch.dylib 0x00007fff7e0a09f9 _dispatch_root_queue_drain + 515
20 libdispatch.dylib 0x00007fff7e0a07a5 _dispatch_worker_thread3 + 101
21 libsystem_pthread.dylib 0x00007fff7e3f0169 _pthread_wqthread + 1387
22 libsystem_pthread.dylib 0x00007fff7e3efbe9 start_wqthread + 13

Long story short, the issue turns out to be having connection logging enabled.  That’d been turned on many months before in order to debug a different stupid Mail bug, and had been simply left on (deliberately IIRC, since Mail tends to bug-out quite often, so why not have logs already available when it comes time to debug it yet again?).

Connection logging is enabled or disabled by opening the “Connection Doctor” (Window menu > Connection Doctor) and using the checkbox titled “Log Connection Activity”.

So how do you get to that checkbox when Mail crashes on launch?  Well, in this specific instance I was able to disable all mail accounts via System Preference’s Accounts pane, launch Mail, disable logging, quit Mail, re-enable all mail accounts via System Preferences, and then relaunch Mail to have it finally actually work.

From even just brief web searching, it’s clear that this issue has been present and well-known in Mail for a really long time.  Sigh.  Apple’s protestations that they care about software quality, or the Mac, are relentlessly undermined by their actual actions.

ProPhoto RGB vs JPEGs

Most common photo editors – e.g. Lightroom – let you choose the colour gamut to use for exported photos.  In Lightroom (at time of writing in January 2018) you have a fairly short list, of today’s common options – sRGB, Display P3, Adobe RGB, and ProPhoto RGB.  Since we’re all obsessive nerds, that we’re given an option dictates that we must make an explicit choice.  More pragmatically, the default in Lightroom – and many other photo editors – is sRGB, which is the one option that’s definitively wrong, so in this case you really do have to change it to something else, if you care about image quality at all.

So, what should you choose?  Well, obviously you want your exported photos to maintain as much of the colour gamut they contain as possible, and as accurately as possible – as part of the general principle that you want it to be the highest quality and as close to what you see on your screen as possible.  Modern digital cameras are capable of capturing far more than the sRGB space, and modern displays are also capable of larger gamuts too (typically Adobe RGB or Display P3, at time of writing, if not the union of both).  Thus why sRGB is unequivocally the wrong option (and any purported counter-arguments about colour calibration issues in web browsers and so forth are moot, because all decent web browsers handle colour management correctly & intuitively, and anyone not using one of those browsers clearly doesn’t care about a lot of things, least of all colour accuracy).

So then it’s just a question of which colour space is bigger, right?  That’s easy – ProPhoto RGB is huge.  A complete superset of all the others.  It actually encompasses colours that don’t even exist as far as the average human is concerned, because they’re outside our visual range.  So just use that, right?

Yes.  Maybe.  It depends.

The thing is, if you increase the colour gamut you encode your image in, you reduce the precision of your colours, all other things being equal.  Because you’re taking e.g. 8 bits, so 256 possible values, and spreading them out over a wider spectrum.  Thus each “bucket” – digitally quantised colour – is going to be bigger, coarser, and have a wider margin of error.  What this can mean in practice is visible banding in images which “should” be higher quality, because they have a much bigger colour gamut!

Larger colour gamuts really need correspondingly larger bit depths, in order to avoid sacrificing colour accuracy (or in plain terms, to avoid visible banding or posterisation).

Thus, if you’re exporting as ye ol’ JPEGs (an image format that’s just not very good, though it’s had a good run at over twenty-five years old at this point) where you’re stuck with 8 bits per pixel, it’s probably a bad idea to use ProPhoto RGB.  It’s too likely that in practice you’ll see nasty banding.  Instead, you’re probably better off striking a compromise and choosing either Display P3 or Adobe RGB, which aren’t so much bigger than sRGB that banding is often more visible, but are fully representable on many contemporary displays.  In theory as displays get better – i.e. wider gamuts – you’d want to upgrade, but in reality JPEG should be long dead before we get the next significant jump in real-world display gamuts, and their successor format(s) will undoubtably support much higher bit depths, eliminating this trade-off.

On the other hand, if you’re already exporting in modern formats – e.g. HEIF – where 10-bit (or better) bit depths are supported, you can consider extra large gamuts like ProPhoto RGB (just make sure you then use greater bit depths, as HEIF also supports 8-bit channels, and some software will still default to that).  It becomes more of a question of your target audience, your expectations for the longevity of that particular rendering of the photo, etc.

And if you’re using 16-bit colour depths, such as are options for TIFFs or other typical intermediary formats (e.g. when going from Lightroom to Photoshop, or vice-versa), then ProPhoto RGB is the best option, because there are no practical downsides.  Today ProPhoto RGB probably far exceeds the colour gamut your camera(s) can actually capture, but that’s okay – your camera(s) can probably capture more than just Adobe RGB or Display P3 too, and with 16 bits per pixel you’ve got plenty of colour resolution, so why sacrifice your camera’s capabilities?

Addendum

This still leaves the choice of Display P3 vs Adobe RGB, for your typical web (etc) exports.  I’ve been using Adobe RGB myself for a long time, since that was basically the next step up in displays for the longest time.  However, since Apple has delivered Display P3 to the world, Display P3 almost overnight became far more commonly supported in the real world.  Remember that any modern iPhone, iPad, or iMac supports Display P3, and most quality standalone PC monitors do also.  There’s also an argument to be made that it is a more practical expansion on sRGB, since it increases not just your greens but also your reds:

sRGB vs AdobeRGB vs DCI-P3
(image courtesy of Smeterlink on Stackexchange)

Keyboard autocompletes

Apparently if you get bored enough you start just playing with the keyboards installed on your iPad.  Those that have the suggestion bar at the top can make some interesting ‘poetry’.  You just keep tapping in the same place, or in some simple pattern across the N suggestions.  Some are just bemusing drunk gibberish, but some are actually almost insightful.  For example:

Microsoft’s “Word Flow”:

  • I have to be a good day and night and day and night and day and night and day and night and day and night and day…
  • I’m going on with your friends are for convenience and the rest in the morning to the public health care system and a few minutes and a few minutes and a few minutes and a few minutes and the rest in the morning…
  • I think you are not responsible for any other person in my life.

Apple’s built-in keyboard:

  • I’m not going home after a while but I’ll probably get home and go to get home from home and work on a Friday or just for the next few days hope I can be a bit more fun with you and you can get me some good morning text.
  • You don’t get a chance but they have the right hope that your team will have you back.
  • I’m not a fan of a good day but it has been a bit fun and I have no hope for any reason.