Dock unread count is inaccurate Every couple of days Mail.app stops showing the unread message count on the Dock icon. Restarting the application brings it back immediately.
In Preferences-&gt;General, I have Dock unread count linked to a smart mailbox that excludes a handful of folders.
Is this a known issue, and is there a fix?
UPDATE:
The problem just recurred, and I notice that when I open the smart mailboxes list, the mailbox I have Dock unread count linked to also doesn't show an unread count, even though viewing the smart mailbox contents has some messages marked as unread.
So the problem seems to be related to how unread counts are calculated for smart mailboxes.
UPDATE 2:
I've reopened the question. Things were going pretty well for a few days with the solution I posted in the answer. But today I'm seeing the opposite problem: the Dock count is 3, but there are no unread messages in any of the folders that are supposed to be counted. When I view the smart mailbox, it's empty. And marking messages as unread adds them to the smart mailbox, but the badge in the dock doesn't change.
As in the past, restarting Mail corrects it.
I think I might have found a solution.
I added the following condition to the smart mailbox that the unread count is linked to:

Message is unread

Before I made this change, I noticed a significant lag between marking/unmarking read messages and the unread count on the smart mailbox and the dock badge changing. When I added this condition, the changes were immediate.
I suspect part of the problem may be that some of my folders (including one of my inboxes) have hundreds or thousands of read messages.