johannh.me
← writing
/ #browsers

Why tab titles lie

A short investigation that ended somewhere I did not expect.

It started with a bug report: a tab that said “Loading…” long after the page had loaded. The obvious answer — a stuck document.title write — was wrong. The real answer involved the back/forward cache, a pagehide handler, and an assumption about event ordering that had been true for exactly as long as nobody tested it.

The chain

The page set its title in a visibilitychange handler. On restore from the cache, visibilitychange fired, but the frame that would have painted the new title was coalesced away because the tab wasn’t foregrounded yet. The title update landed in a frame that never happened.

The fix was one line. Understanding why it was one line took a day and a half, and a lot of console.timeStamp.

What I took away

Tab titles are a cache of a cache of a signal. When they disagree with reality, the interesting question is never “which write won” — it’s “which frame got dropped.”