Hi, when i tried to use Coil image to load SVG, it throws this error in my log:
can't render image: load image failed
i already installed SvgDecoderFactory but it wont load ? But it loads just fine on android platform. Does anyone knows how to solve this ? thank you.
ferdialif02
10/21/2024, 12:50 PM
Turns out the SVG image have PNG image embedded in it, but not sure why it fails to load on non Android platform ?
ferdialif02
10/21/2024, 12:51 PM
Then i decided to extract the base64 from the svg and then use toImageBitmap extension function to load the Image
g
Greg Williams
07/25/2025, 2:47 PM
I have this same issue with coil 3.3 in my CMP project. I have the ktor darwin client lib in my appleMain.dependencies, I've included the coil and coil-svg library in commonMain.dependencies, I even added the SvgDecoder.Factory() to the ImageLoader. Android loads the svg with no problems, but I get 'can't render image: load image failed' in iOS. If I switch the file for a png file, it loads with coil with no problems on both platforms.
Greg Williams
07/25/2025, 3:14 PM
Ah, it looks like iOS can't handle base64 encoded svg files via coil. I found another svg file that doesn't just base64 encode a png and that worked fine on both platforms. Weird that it does work on Android. 🤔
f
ferdialif02
07/25/2025, 3:19 PM
yes it does works on android but not on ios, strange haha, i ended up implementing my own logic, thanks to gpt as well haha