-
Notifications
You must be signed in to change notification settings - Fork 2.1k
bug: Icons do not display when the svg is loaded from a file:// URL by Safari (iOS and MacOS X) #1298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
triage
New issues
Comments
sthompson-crestron
added a commit
to sthompson-crestron/ionicons
that referenced
this issue
Nov 5, 2023
… the definative signal that an SVG download succeeds. Safari does not set the status to 200 when loading the image from a file:// URL
PR Created |
christian-bromann
added a commit
to christian-bromann/ionicons
that referenced
this issue
Apr 16, 2025
Fixed in #1447 |
christian-bromann
added a commit
to christian-bromann/ionicons
that referenced
this issue
Apr 21, 2025
christian-bromann
added a commit
to christian-bromann/ionicons
that referenced
this issue
Apr 25, 2025
christian-bromann
added a commit
that referenced
this issue
May 2, 2025
* chore: update project dependencies * remove lerna * update build * plugin fixes * Icons do not display when the svg is loaded from a file:// URL in Safari fixes #1298 * Update path fill in warning-outline.svg exclamation mark * set currentColor - fixes #1420 * add bell tag to notifications icon - fixes #1090 * add sliders and filters tags to option icon - fixes #1060 * add loveseat tag to bed icon - closes #503 * add contacts tag to people-circle closes #779 * fix data.json * update data.json * set up prettier * fix contributing link * prettier after rebase * add missing rimraf * add more comments * run prettier as part of the build * set module resolution to bundle * consolidate contributing guidelines and coc as part of the root directory * fix link * copy svg into www * cut me some visual slack * Update readme.md Co-authored-by: Brandy Smith <[email protected]> * Update package.json Co-authored-by: Maria Hutt <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Maria Hutt <[email protected]> * remove generating collections * ensure all directories exist * only define snapshot tolerance in config * update dependencies * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <[email protected]> * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <[email protected]> * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <[email protected]> * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <[email protected]> * prettier * update release pipeline * fix exports * recommend to use esm.sh as cdn --------- Co-authored-by: Brandy Smith <[email protected]> Co-authored-by: Maria Hutt <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current Behavior
I've built an ionic/angular application that includes an ion-icon on an HTML page. I don't think that Angular is significant, that's just what I was working with.
The application is built to be displayed from a file:// URL. The application is built, bundled into an iOS application and then displayed in a WKWebView directly from the file system (no server).
Because of a bad interaction between Safari on the iOS device, and some code in the ionicons source, the icons will no display.
I have reproduced the issue on MacOS using Safari in that environment too.
Expected Behavior
I would expect the icon to display. The content (the svg file) is successfully loaded by the browser, but that success is ot reported to ionicons in the expected way.
Steps to Reproduce
I built an application sample in this repo: https://github.com/sthompson-crestron/ionicon_missing
I am using a MacBook Pro running MacOS 13.6.1 (Ventura) and Safari Version 17.1 (18616.2.9.11.9, 18616).
For iOS I am using iOS 17 with whatever version of Safari I has. This is probably easier to demonstrate on a laptop as to demonstrate it on iOS you need an application to host the web site.
From the repo above, I build the application with the command
yarn run build --configuration development
. The result is placed in thewww
folder. From there open thewww/index.html
file.I expect this page to show a very large instance of the "star" ionicon. It does not display.
Code Reproduction URL
https://github.com/sthompson-crestron/ionicon_missing
Additional Information
The fundamental problem is an interaction between the way safari treats a file URL through the browser's
fetch(url)
call and code in ionicons. When getting to the svg file for the icon, ionicons runs this code:The URL that "fetch" is presented with will be something like:
file:///Users/sthompson/Projects/TempPlaygrounds/some_app/www/svg/star.svg
Safari will fetch the file, but it returns a status code of 0 instead of a 200:
The file has been successfully downloaded, but the ionicons code is checking "rsp.ok". The Response's
ok
property tells you if the status code is in the range 200-299 and Safari's response of0
is clearly not in that range. So ionicons doesn't even try to get the content back from the request. However, if you go ahead and try to accessrsp.text()
the data will be there.The status code of 0 may be a bug in Safari. But it is possible to work around that bug. I got it to work by modifying my local copy to ignore the "rsp.ok" property, check, access the
text()
for the request, and I added a.catch
to handle failure cases. Perhaps doing that only in the case that the resonse status is 0 would be an even narrower fix.Including the script from the usage page:
Will work around the issue because the svg files are loaded from the web. However our application is designed to be used in environments where the user may not have access to the internet (say on a ship under-way at sea). So having access to the icon images from the file system is important.
The text was updated successfully, but these errors were encountered: