[Webkit-unassigned] [Bug 213770] New: Safari on iOS doesn't fire visibilitychange event when the tab is closed

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 29 20:24:57 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=213770

            Bug ID: 213770
           Summary: Safari on iOS doesn't fire visibilitychange event when
                    the tab is closed
           Product: WebKit
           Version: Safari 13
          Hardware: iPhone / iPad
                OS: iOS 13
            Status: NEW
          Keywords: InRadar
          Severity: Major
          Priority: P2
         Component: DOM
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: spammingthrowaway at gmail.com
                CC: cdumez at apple.com, graouts at apple.com,
                    jason.gissing at omnis.net, rniwa at webkit.org,
                    simon.lieschke at orionhealth.com,
                    webkit-bug-importer at group.apple.com,
                    webkit-unassigned at lists.webkit.org

Created attachment 403167

  --> https://bugs.webkit.org/attachment.cgi?id=403167&action=review

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).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200630/bd4d4b3f/attachment.htm>


More information about the webkit-unassigned mailing list