Monday, June 1, 2020

Apple Mail Randomly Becomes the Frontmost Application

Philipp Defner (also: Hacker News):

Since macOS 10.12 there’s a bug in Apple Mail that causes it to randomly become the frontmost application. If you are in full screen mode — like when you are giving a talk or watching a movie — it opens itself up in split view mode where it takes up half the screen while your other main window is being resized.

[…]

After some research it became clear that it’s related to Gmail and I’m not exactly the only one[…]

As a developer of a Mail plug-in, I’ve been hearing about this for years. People assume it must be caused by third-party software, but in fact it can occur with a clean macOS installation. I’m not sure that it’s limited to Gmail accounts. It may just affect more Gmail users because (a) there are a lot of Gmail users, and (b) Gmail’s IMAP implementation is particularly unreliable, often unavailable for short periods of time.

vladharbuz:

It seems to happen because of improper error handling. If you look closely at the app in the instant it opens, your affected account will have a “disconnected” symbol next to it in the sidebar. However, it goes away before an error can be shown.

My theory is: there is a momentary connection issue with these G Suite accounts, and Mail.app starts to show an error by focusing itself, but the error is resolved so quickly it doesn’t actually get to show the “connection problems” modal.

evanelias:

In my experience, if you always hide the Mail window (cmd-h) instead of closing it (cmd-w), it won’t ever pop back up. Takes a while to retrain the muscle memory though!

Update (2020-06-02): mkalina:

Not only with Gmail. Same happens with O365/Exchange, too.

13 Comments RSS · Twitter


I can confirm Hide instead of Close is a workaround, albeit a dumb one. I’ve also confirmed after temporarily deactivating Gmail that the bug doesn’t happen. Further evidence is that I sometimes see an error on my Gmail account when refreshing iOS Mail, but of course goes away when I try refreshing again.


This has been annoying me for at least 2 if not 3 macOS releases now and incidentally finally filed a bug in Feedback Assistant.

I don’t know whether its related to G-Suite or not… because none of my G-Suite accounts (work, university) are actually turned on in Mail in the first place.

I have considered giving up on Mail entirely but Airmail 3 seemed mostly abandoned/incomplete in comparison and Spark also hasn’t exactly struck the note I want it to.


Or use Marco Arment’s Quitter app to hide it automatically after, say, 10 minutes of inactivity


I wish Apple would make it impossible for any app to come to the front on its own. Mail isn’t the only one. It’s annoying to have any app or alert interrupt the task/window that’s right in front of me.


@Ben I wish there were a Notification Center–like API for reporting errors. (You get rejected from the Mac App Store for posting errors to Notification Center.)


YES.

I’m not the only one then. I confirm that hiding solves the problem and that when in full screen it splits it.


When I first saw this I was wondering why I have never seen this behaviour when I use Mail so much - but it is likely because I long since turned off automatic-email checking (which is really distracting if you get a lot of email). Which gives weight to the "its an error that is quickly resolved" idea since I would already be in Mail when checking for mail.


Does hiding instead of closing also solve the issue of being unable to quit Apple Mail when you've closed its window?

This issue that happens once in a while has been there for years and is not related to Gmail.


I can confirm that this also happens without a Gmail account.


I reported this bug back in Sep 2017 (FB5355693). It was promptly closed as a duplicate but now shows “ Resolution:Potential fix identified - For a future OS update”, so I guess there’s still hope.


I wish Apple would make it impossible for any app to come to the front on its own.

Ironically, Windows now blocks apps trying to get focus so aggressively that I run into timing issues — if my window doesn’t appear quickly enough, it never comes to front without user interaction. If a window requests coming to front, Windows now tends to show it by blinking the taskbar icon.

I’m kind of not sure why focus-stealing is such a hard problem to solve.

As for this bug in particular… yup, I run into that. Particularly embarrassing when you’re presenting something in full screen and Mail slides in to take half of it. Haven’t tried hiding instead; it does seem plausible that that would help (I prefer closing windows that I don’t actively use).


I've never seen this, on any version up to 10.14, and I have Mail running and visible 100% of the time my Mac is on. FWIW, I use normal Gmail, but not a custom G-suite mail account.


@ Ken: try closing(!) the main message list window and leaving it closed like that for a few hours. IME, it comes back when you least expect/want it to.

Leave a Comment