Bug 219038 - Load event fires multiple times
Summary: Load event fires multiple times
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-11-17 09:49 PST by Milan Keser
Modified: 2020-12-02 18:45 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Keser 2020-11-17 09:49:15 PST
For some reason we get duplicate load events in Safari 14 and 13 when we redirect the page during the onload event.

userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15

How to reproduce:

 Create an html page
 Add onload listener to body element
 In onload listener click the button
 Click on button changes the location.href and goes to another page

What we do:
 
 We have a tracking tool that is injected as the first script in head tag.
 We register load listener and create a beacon with metrics when load fires.
 For some reason beacon sending fails if we redirect in onload event listener that is added to body element.
 We get "failed to get a response" response from that beacon sending.
 However that beacon somehow gets to the server with duplicate load event data.
 This only happens on Safari 13 and 14, we are running this also on safari 12 and all other major browsers and we do not see this issue.
Comment 1 Milan Keser 2020-11-17 09:55:37 PST
Other possibility is that the failed beacon sending was trying to be resend multiple times from browser, but we cannot really be sure since browser shows only one request in console
Comment 2 Smoley 2020-11-18 10:41:03 PST
Thanks for filing, if possible please link to a live test case.
Comment 3 Radar WebKit Bug Importer 2020-11-18 10:41:15 PST
<rdar://problem/71546102>