WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 199854
213770
Safari on iOS doesn't fire visibilitychange event when the tab is closed
https://bugs.webkit.org/show_bug.cgi?id=213770
Summary
Safari on iOS doesn't fire visibilitychange event when the tab is closed
spammingthrowaway
Reported
2020-06-29 20:24:57 PDT
Created
attachment 403167
[details]
Test page to reproduce bug +++ This bug was initially created as a clone of
Bug #199854
+++ Cloning this bug since it's fairly old and I'm still encountering on iOS 13. I've run into a similar issue with a page that needs to fire a POST request when being closed for analytics and cleanup. Using document.visibilitychange works on chrome, firefox, and edge on windows, as well as chrome on android. But, upon investigation it seems Safari fires this event only when hiding the page by pressing the home button or switching to a new tab. When closing the tab or navigating away to a different page, document.visibilitychange is never fired. See the test-page in the cloned bug, as well as what I've attached which adds a cookie logging the visibilitystate upon document.visibilitytransition events. Cookies will be added when pressing the home button or opening a new tab, but not when closing or navigating away from the page. The closest workaround I've found is to use the focus and blur events which are being fired properly, but this presents problems with being triggered on desktop in cases that they shouldn't be (i.e. the user clicking off the page). visibilitychange should be triggered in these cases; see
https://www.igvita.com/2015/11/20/dont-lose-user-and-app-state-use-page-visibility/
(which seems to document this as bugged dating back to 2015).
Attachments
Test page to reproduce bug
(1.12 KB, text/html)
2020-06-29 20:24 PDT
,
spammingthrowaway
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2020-07-01 09:27:56 PDT
> Cloning this bug since it's fairly old and I'm still encountering on iOS 13.
This is not a good way to raise attention. A new bug is less visible than a comment on the original one, and far more confusing.
> I've run into a similar issue with a page that needs to fire a POST request when being closed for analytics and cleanup.
Beacons may be able to solve this use case. Even if visibilitystate were fired, the POST would not necessarily be sent - a closed page is a closed page, everything is being cleaned up. *** This bug has been marked as a duplicate of
bug 199854
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug