RESOLVED FIXED 265000
FontFace with data: URI crashes Worker
https://bugs.webkit.org/show_bug.cgi?id=265000
Summary FontFace with data: URI crashes Worker
Jacob Bandes-Storch
Reported 2023-11-16 19:04:30 PST
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
youenn fablet
Comment 1 2023-11-20 02:12:54 PST
youenn fablet
Comment 2 2023-11-20 04:08:35 PST
It might be the promise never rejects/resolves.
youenn fablet
Comment 3 2023-11-20 06:40:07 PST
Jacob Bandes-Storch
Comment 4 2023-11-20 22:34:17 PST
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
Comment 5 2023-11-28 07:44:06 PST
Committed 271213@main (b1f4d8147c3c): <https://commits.webkit.org/271213@main> Reviewed commits have been landed. Closing PR #20742 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.