SDWebImage / SDWebImageSVGCoder

A SVG coder plugin for SDWebImage, using Apple's built-in framework
MIT License
103 stars 34 forks source link

Crash in sd_setImage #22

Closed nirleshem closed 4 years ago

nirleshem commented 4 years ago

Issue reproduced while scrolling in a basic UITableView implementation.

Screen Shot 2020-03-27 at 23 11 59
dreampiggy commented 4 years ago

@nirleshem See more : https://github.com/SDWebImage/SDWebImageSwiftUI/issues/87

Did you use the opacity CSS attr in your SVG CSS style ? You should replace it with rgba or fill-opacity instead.

dreampiggy commented 4 years ago

See: https://github.com/SDWebImage/SDWebImageSVGCoder#compatibility-for-coresvg-framework

dreampiggy commented 4 years ago

@nirleshem Any update about this ?

SebastianKTDC commented 4 years ago

I am also getting this crash

dreampiggy commented 4 years ago

@SebastianKTDC Is this workaround solve your problem ? https://github.com/SDWebImage/SDWebImageSVGCoder#compatibility-for-coresvg-framework

Or new cases ? Please provide your SVG files

SebastianKTDC commented 4 years ago

Hello @dreampiggy I just checked my svgs and there seems to be no opacity on path applied. here is the image https://sentrycdn.s3.eu-north-1.amazonaws.com/avatar/action.svg

SebastianKTDC commented 4 years ago

I am also using both this plugin and sdwebimage trough SPM

dreampiggy commented 4 years ago
<g fill="#161616" mask="url(#d)" opacity=".5">

This same issue. The opacity attribute and fill can not been combined together by Apple's CoreSVG.

Use the fill color with alpha value instead.

dreampiggy commented 4 years ago

Change this into:

<g fill="rgba(22, 22, 22, .5)" mask="url(#d)">

May solve the problem. I can update the readme, this does not limited only with <path>

dreampiggy commented 4 years ago

image

But this seems not what web browser rendered

SebastianKTDC commented 4 years ago

thanks, I will test it out

SebastianKTDC commented 4 years ago

it works, thanks for the help. I fixed my images and all good now

dreampiggy commented 4 years ago

I've already fired Radar for this: FB7670447

This crash seems occur on iOS only, same SVG files on macOS does not cause crash.

zulfkhar00 commented 4 years ago

@dreampiggy I got the same problem and when I try to import SVG file into SF Symbols app it cannot validate it, so I cannot export it. Also, where should I use this kind of html code? I am stuck

dreampiggy commented 4 years ago

@Zulfhar Xcode 11 does not support import raw SVG files into App's Asset Catalog. The SVG file only recognized as SF Symbols (SF Symbols and SVG is two different thing, SF Symbols are collection of multiple SVGs).

So, for your own SVG images, you can put it into your App's working directory (copy resources into your ipa), treat it as Raw Data, load it from Bundle in runtime by using the code sample in readme. Or you can donwload from network.

There are also tricks to let Xcode import your true SVG into Asset Catalog, but not officially supported, see:

https://twitter.com/DreamingPiggy/status/1244259615602118657