Skip to content
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

Crash on svg image #43

Closed
AndriiPetrovDev opened this issue Apr 4, 2023 · 8 comments · Fixed by #44
Closed

Crash on svg image #43

AndriiPetrovDev opened this issue Apr 4, 2023 · 8 comments · Fixed by #44

Comments

@AndriiPetrovDev
Copy link

AndriiPetrovDev commented Apr 4, 2023

Try to open this image https://openseauserdata.com/files/b809fe0925eb3629bb1d3edb1fafcc88.svg
SDWebImage crashes because "NSFont can't be nil"

@dreampiggy
Copy link
Collaborator

dreampiggy commented Apr 6, 2023

Seems SVG use a font which native iOS platform does not embed.

Does this a Objective-C exception (or C++ exception) which can be handled by our user level code ?

If so, we can add a protect here. To make it Load SVG failed but not crash your user app.

@dreampiggy
Copy link
Collaborator

font-family="宋体"

@AndriiPetrovDev
Copy link
Author

It will be really nice.

@AndriiPetrovDev
Copy link
Author

Can we solve such problems for all possible alphabets?

@dreampiggy
Copy link
Collaborator

Does this a Objective-C exception (or C++ exception) which can be handled by our user level code ?

Did you test this ?

@osmantufekci
Copy link

osmantufekci commented May 3, 2023

There is another crash, EXC_BADACCESS on SDCGSVGDocumentWriteToData method. But it happens only at first load, subsequent load attempt won't crash. I also tried with SDWebImageSVGNativeCoder but this time it shows the file as pure black.

This is the svg file;
general

as text:
general.txt

@dreampiggy
Copy link
Collaborator

dreampiggy commented May 5, 2023

SDCGSVGDocumentWriteToData is used to re-export UIImage to NSData. So why do you meanBut it happens only at first load, subsequent load attempt won't crash ?

I don't think these two is the same issue. SDWebImage itself should not re-encode SVG image to NSData if you don't specify this (using thumbnail or transformer)

Actually, the SVG export feature is not really useful in general, because SVG is vector image format. For the re-export, you can just save the data (download from SVG URL) and re-read it

@dreampiggy
Copy link
Collaborator

dreampiggy commented May 5, 2023

Is this logic bug ? Any demo can reproduce your But it happens only at first load, subsequent load attempt won't crash ?

For normal WebImage loading process, it should not trigger re-encode logic.

  1. Query Cache failed
  2. Download SVG Data
  3. Create UIImage (using CoreSVG)
  4. Store Data to Disk, UIImage to Memory
  5. Finish Callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants