mchoe / SwiftSVG

A simple, performant, and lightweight SVG parser
Other
1.92k stars 229 forks source link

SVG layers dissapearing #127

Open Arneoldenhave opened 5 years ago

Arneoldenhave commented 5 years ago

Hi,

I'm currently working on a project that requires SVG's as Icons. I've implemented them using the svgLayer in closure as demonstrated in the documentation.

Everything works fine until I put my views in a collectionview. If I change the icons in the view upon dequeuing them from the collectionview the old icons disappear. More specifically when new cells are dequeued and a new instance of the svgLayer is created, while anther of the same kind(url) lives in memory, the older one disappears and appears in the new cell.

I've been sniffing around in the module and saw a cache layer in the app. However the svgLayerCopy that gets explicitly created displays the same behavior.

So far I really like the lightweight approach of the API and would really like to continue working with SwiftSVG.

Is there a way to combat this?

zengadget commented 5 years ago

I'm seeing the same issue, some icons disappear on second load of the same icon. (In my case it is not connected to collection view) I have two same chevron icons on screen and they both appear correctly the first time after launch but when navigating off the screen (releasing) and coming back one of the icons disappears. Seems to be some kind of caching issue. @Arneoldenhave have you found any solution for this?

Arneoldenhave commented 5 years ago

@matejukmar matejukmar. Unfortunately not, we have since moved on to MACAW, which, with some workarounds, can be used for the same purposes.

I have posted a usable icon class in this post: https://github.com/exyte/Macaw/issues/603 you can take a look at.

Good luck!

zengadget commented 5 years ago

@Arneoldenhave I drilled down the code and found the issue. Here I raised the PR with the fix, if it is still relevant to you: https://github.com/mchoe/SwiftSVG/pull/137

Arneoldenhave commented 5 years ago

Nice man!

I also tried just copying those layers, but couldn't get it to work!

Good luck out there... ;)