Bug 205942

Summary: The visibilitychange event does not fire on iOS when entering the tab switcher
Product: WebKit Reporter: Philip Walton <philip>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: cdumez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 13   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=207256

Philip Walton
Reported 2020-01-08 11:34:47 PST
** Current behavior: ** When opening the tab switcher in Safari on iOS, the `visibilitychange` event will only fire once a user switches to a new tab. If the user instead closes the tab, then no `visibilitychange` event is fired (neither is `pagehide`, `beforeunload`, or `unload` FWIW, though I don't think those events should offer the same guarantees as `visibilitychange`). STR: 1. Visit https://visibilitychange-logger.glitch.me on an iPhone 2. Click the tab switcher button in the bottom right 3. Close the tab 4. Re-visit https://visibilitychange-logger.glitch.me and notice that no events were logged (note: `visibilitychange` events *are* logged if you actually switch to another tab) ** Proposed behavior: ** In my opinion, the `visibilitychange` event should fire as soon as the tab switcher button is pressed. That would guarantee that at least the hidden state is triggered regardless of whether the user switches tabs or closes the tab. (This is also consistent with how the `visibilitychange` event fires on Chrome on both Android and iOS) Alternatively, if https://bugs.webkit.org/show_bug.cgi?id=151234 can be fixed to ensure the `visibilitychange` event fires any time the page goes away (including closing it from the tab switcher), that would also solve this problem.
Attachments
Radar WebKit Bug Importer
Comment 1 2020-01-09 10:28:57 PST
Note You need to log in before you can comment on or make changes to this bug.