[Webkit-unassigned] [Bug 284067] New: Preloaded Resources Fetched Twice in Safari with CORS Enabled
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Dec 4 14:18:34 PST 2024
https://bugs.webkit.org/show_bug.cgi?id=284067
Bug ID: 284067
Summary: Preloaded Resources Fetched Twice in Safari with CORS
Enabled
Product: WebKit
Version: Safari 18
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: Page Loading
Assignee: webkit-unassigned at lists.webkit.org
Reporter: chris.simpson at unity3d.com
CC: beidson at apple.com
Created attachment 473463
--> https://bugs.webkit.org/attachment.cgi?id=473463&action=review
Reproduction
Overview:
I'm trying to preload a file in my html that I later fetch, but the preload just ends in an additional xhr request being sent, and the resource being downloaded in full twice. The console also warns that the preload went unused. If I disable cors in the requests, the preload works correctly and only one request/download is visible in the network tab of the web inspector.
Here's a trivial reproduction demonstrating the behaviour. Note that data1 and data2 are just arbitrary data files. In this reproduction, data1 is fetched twice while data2 is fetched only once. I've verified the behaviour both on an M1 Max MBP running 15.1.1 and an iPhone 14 Pro running 18.1.1
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preload" as="fetch" crossorigin href="data1">
<link rel="preload" as="fetch" href="data2">
</head>
<body>
<script>
fetch("data1", {mode: "cors"})
fetch("data2", {mode: "no-cors"})
</script>
</body>
</html>
```
Steps to Reproduce:
1. Unzip and host the attached safari_bug.zip
2. Open the web inspector's Network tab
3. Load the hosted content
4. Observe the network requests
Actual Results:
data1, the crossorigin file, is downloaded twice - once via the preload link as an xhr request and again as a fetch request in the body's script. data2 is downloaded only once with no-cors via the preload link.
Expected Results:
Both data1 and data2 are downloaded only once via their preload link.
Additional Information:
By comparison, Chrome handles preloading data1 successfully, but doubles requests data2 which is the inverse of Safari's behaviour. Firefox allows both to be preloaded properly.
Bug 236009 looks very similar, I'm not sure if it's related, but has been open since early 2022.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20241204/91c8e2a3/attachment.htm>
More information about the webkit-unassigned
mailing list