<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>194897</bug_id>
          
          <creation_ts>2019-02-21 06:22:40 -0800</creation_ts>
          <short_desc>navigator.sendBeacon does not work on visibilitychange callback for document unload</short_desc>
          <delta_ts>2022-07-05 14:11:51 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.14</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>151234</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=116769</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=151234</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=151610</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Bastien Caudan">bastien.caudan</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>code</cc>
    
    <cc>mike</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1508500</commentid>
    <comment_count>0</comment_count>
    <who name="Bastien Caudan">bastien.caudan</who>
    <bug_when>2019-02-21 06:22:40 -0800</bug_when>
    <thetext>With the example from the beacon spec (https://w3c.github.io/beacon/):

document.addEventListener(&apos;visibilitychange&apos;, function() {
  if (document.visibilityState === &apos;hidden&apos;) {
    navigator.sendBeacon(&apos;/collector&apos;, data);
  }
});


From manual tests on hidden cases, navigator.sendBeacon is triggered correctly when:
- the browser is minimized.
- the document is not the active tab

But navigator.sendBeacon is not triggered when:
- the browser unload the document

Other browsers that support the Beacon API allow these requests to be sent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508868</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-02-21 20:49:37 -0800</bug_when>
    <thetext>&lt;rdar://problem/48301429&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1546983</commentid>
    <comment_count>2</comment_count>
    <who name="Daniel">code</who>
    <bug_when>2019-06-21 14:08:29 -0700</bug_when>
    <thetext>The visibilitychange event don’t fire at all during unload. This is a duplicate of issue #116769.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1691793</commentid>
    <comment_count>3</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2020-09-24 23:33:46 -0700</bug_when>
    <thetext>See the https://volument.com/blog/sendbeacon-is-broken#comments comments discussion for some real-world pain points developers are hitting due to this. (So that not only do we need to make developers aware that they shouldn’t be trying to use unload/onunload with sendBeacon(), and that they instead need to  visibilitychange — but *also* need to check pagehide (because we don’t yet have visibilitychange working interoperably for them across the web platform).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1880799</commentid>
    <comment_count>4</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2022-07-05 14:11:51 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 151234 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>