Bug 265000
| Summary: | FontFace with data: URI crashes Worker | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Jacob Bandes-Storch <jacob> |
| Component: | New Bugs | Assignee: | youenn fablet <youennf> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | fantasai.bugs, mattwoodrow, vitor.roriz, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | macOS 14 | ||
Jacob Bandes-Storch
Steps to reproduce:
Tested in Safari 17.1 (19616.2.9.11.7) and Technology Preview (Safari 17.4, WebKit 19618.1.5.2)
1. Create a HTML file with the following content:
<script>
new Worker(URL.createObjectURL(new Blob([`(async()=>{
try {
await new FontFace("ABC", "url(data:font/woff2,abcd) format('woff2')").load().catch(e=>console.error("rejected",e));
console.log("done")
} catch(e) {
console.error("caught",e)
}
})()`])))
</script>
2. Load the page, open the console and see the following output:
[Error] Cannot load data:font/woff2,abcd.
[Error] Failed to load resource: Cross origin requests are not allowed when using same-origin fetch mode. (data:font/woff2,abcd, line 0)
Notice that the "rejected", "caught", and "done" log messages do not appear -- the Worker seems to be completely dead.
Expected behavior:
- Ideally, this method of font loading would just work.
- If loading the data: URL is not permissible, then the error should be catchable via .catch() or try/catch, it should not break the entire Worker.
Workaround:
- Using fetch() to load the data: url and passing an ArrayBuffer to the FontFace constructor seems to be a valid workaround. (example: https://github.com/foxglove/studio/pull/7139)
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
youenn fablet
<rdar://118546120>
youenn fablet
It might be the promise never rejects/resolves.
youenn fablet
Pull request: https://github.com/WebKit/WebKit/pull/20742
Jacob Bandes-Storch
Yes, good catch, I guess the `await` in my sample code was a mistake and the worker is not broken :) Thank you for the quick fix!
EWS
Committed 271213@main (b1f4d8147c3c): <https://commits.webkit.org/271213@main>
Reviewed commits have been landed. Closing PR #20742 and removing active labels.