FFImageLoading
FFImageLoading copied to clipboard
Not all SVG images are displayed
Description
I have a list of SVG images to load, but not all images are loaded correctly.
Steps to Reproduce
First image: https://upload.wikimedia.org/wikipedia/de/5/5c/Chelsea_crest.svg Second image: https://upload.wikimedia.org/wikipedia/en/f/fd/Brighton_%26_Hove_Albion_logo.svg
Reproduction Link / Code
ImageService.Instance.LoadUrl(URL)
.LoadingPlaceholder("placeholder.svg")
.WithCustomDataResolver(new SvgDataResolver(200, 0, true))
.WithCustomLoadingPlaceholderDataResolver(new SvgDataResolver(200, 0, false))
.Into(cell.Image);
I have the same issue, any update?
Second one is fixed with: https://github.com/luberda-molinet/FFImageLoading/commit/235348340ee4022fd6222d1d39727389c430960e
First one is related to xml reader:
System.Xml.XmlException: Reference to undeclared entity 'ns_extend'. Line 14, position 43.
at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:2503
at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg, System.Int32 lineNo, System.Int32 linePos) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:2482
at System.Xml.XmlTextReaderImpl.HandleGeneralEntityReference (System.String name, System.Boolean isInAttributeValue, System.Boolean pushFakeEntityIfNullResolver, System.Int32 entityStartLinePos) [0x00068] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:5506
at System.Xml.XmlTextReaderImpl.HandleEntityReference (System.Boolean isInAttributeValue, System.Xml.XmlTextReaderImpl+EntityExpandType expandType, System.Int32& charRefEndPos) [0x0013e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:5480
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow (System.Int32 curPos, System.Char quoteChar, System.Xml.XmlTextReaderImpl+NodeData attr) [0x002a5] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:4752
at System.Xml.XmlTextReaderImpl.ParseAttributes () [0x0039a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:4501
at System.Xml.XmlTextReaderImpl.ParseElement () [0x001df] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:4019
at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x00213] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:3658
at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/mcs/class/referencesource/System.Xml/System/Xml/Core/XmlTextReaderImpl.cs:1168
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r) [0x0001b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs:860
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r, System.Xml.Linq.LoadOptions o) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs:867
at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) [0x00024] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/System.Private.Xml.Linq/src/System/Xml/Linq/XDocument.cs:430
at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/System.Private.Xml.Linq/src/System/Xml/Linq/XDocument.cs:406
at FFImageLoading.Svg.Platform.SKSvg.Load (System.Xml.XmlReader reader) [0x00001] in /Users/daniel/Projects/PublicGithub/FFImageLoading/source/FFImageLoading.Svg.Shared/SkSvg.cs:98
@daniel-luberda I ran into this issue too just now. For example this svg wont load with the component and loads the error image instead. https://secure.ecp123.com/images/icons/Billing.svg
Tks for supporting this Lib over the years @daniel-luberda
Following SVG's aren't displayed, relates to FFImageLoading.Svg.Shared\SkSvg.cs
https://github.com/lipis/flag-icon-css/blob/master/flags/1x1/ke.svg https://github.com/lipis/flag-icon-css/blob/master/flags/1x1/sv.svg
System.NullReferenceException: Object reference not set to an instance of an object
at FFImageLoading.Svg.Platform.SKSvg.ReadPaints (System.Collections.Generic.Dictionary`2[TKey,TValue] style, SkiaSharp.SKPaint& strokePaint, SkiaSharp.SKPaint& fillPaint, System.Boolean isGroup, System.String& fillId, System.String& strokeFillId) [0x00395] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:1300
at FFImageLoading.Svg.Platform.SKSvg.ReadPaints (System.Xml.Linq.XElement e, SkiaSharp.SKPaint& stroke, SkiaSharp.SKPaint& fill, System.Boolean isGroup, System.Boolean isMask) [0x00008] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:1148
at FFImageLoading.Svg.Platform.SKSvg.ReadElement (System.Xml.Linq.XElement e, SkiaSharp.SKCanvas canvas, SkiaSharp.SKPaint stroke, SkiaSharp.SKPaint fill, System.Boolean isMask, System.Threading.CancellationToken token) [0x00048] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:237
at FFImageLoading.Svg.Platform.SKSvg.LoadElements (System.Collections.Generic.IEnumerable`1[T] elements, SkiaSharp.SKCanvas canvas, SkiaSharp.SKPaint stroke, SkiaSharp.SKPaint fill, System.Threading.CancellationToken token) [0x00010] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:221
at FFImageLoading.Svg.Platform.SKSvg.Load (System.Xml.Linq.XDocument xdoc, System.Threading.CancellationToken token) [0x00417] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:209
at FFImageLoading.Svg.Platform.SKSvg.Load (System.Xml.XmlReader reader, System.Threading.CancellationToken token) [0x00000] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:100
at FFImageLoading.Svg.Platform.SKSvg.Load (System.IO.Stream stream, System.Threading.CancellationToken token) [0x00012] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:94
at FFImageLoading.Svg.Platform.SvgDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0019d] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SvgDataResolver.cs:232
at FFImageLoading.DataResolvers.WrappedDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0004e] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\WrappedDataResolver.cs:21
at FFImageLoading.Work.ImageLoaderTask`3[TDecoderContainer,TImageContainer,TImageView].RunAsync () [0x00300] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:618
Tks for supporting this Lib over the years @daniel-luberda
Following SVG's aren't displayed, relates to FFImageLoading.Svg.Shared\SkSvg.cs
https://github.com/lipis/flag-icon-css/blob/master/flags/1x1/ke.svg https://github.com/lipis/flag-icon-css/blob/master/flags/1x1/sv.svg
System.NullReferenceException: Object reference not set to an instance of an object at FFImageLoading.Svg.Platform.SKSvg.ReadPaints (System.Collections.Generic.Dictionary`2[TKey,TValue] style, SkiaSharp.SKPaint& strokePaint, SkiaSharp.SKPaint& fillPaint, System.Boolean isGroup, System.String& fillId, System.String& strokeFillId) [0x00395] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:1300 at FFImageLoading.Svg.Platform.SKSvg.ReadPaints (System.Xml.Linq.XElement e, SkiaSharp.SKPaint& stroke, SkiaSharp.SKPaint& fill, System.Boolean isGroup, System.Boolean isMask) [0x00008] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:1148 at FFImageLoading.Svg.Platform.SKSvg.ReadElement (System.Xml.Linq.XElement e, SkiaSharp.SKCanvas canvas, SkiaSharp.SKPaint stroke, SkiaSharp.SKPaint fill, System.Boolean isMask, System.Threading.CancellationToken token) [0x00048] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:237 at FFImageLoading.Svg.Platform.SKSvg.LoadElements (System.Collections.Generic.IEnumerable`1[T] elements, SkiaSharp.SKCanvas canvas, SkiaSharp.SKPaint stroke, SkiaSharp.SKPaint fill, System.Threading.CancellationToken token) [0x00010] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:221 at FFImageLoading.Svg.Platform.SKSvg.Load (System.Xml.Linq.XDocument xdoc, System.Threading.CancellationToken token) [0x00417] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:209 at FFImageLoading.Svg.Platform.SKSvg.Load (System.Xml.XmlReader reader, System.Threading.CancellationToken token) [0x00000] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:100 at FFImageLoading.Svg.Platform.SKSvg.Load (System.IO.Stream stream, System.Threading.CancellationToken token) [0x00012] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:94 at FFImageLoading.Svg.Platform.SvgDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0019d] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SvgDataResolver.cs:232 at FFImageLoading.DataResolvers.WrappedDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x0004e] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\WrappedDataResolver.cs:21 at FFImageLoading.Work.ImageLoaderTask`3[TDecoderContainer,TImageContainer,TImageView].RunAsync () [0x00300] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:618
Hi, I am using lipis flags too, a lot of them dont appear including hk.svg. I ran the flag through recommended optimizer by documentation, still not rendering.
Did you find a solution @gsgou regarding your flag svgs?
@Edgaras91 for the not-supported SVGs i created PNGs and adjusted the behaviour in a converter.
I also came across this problem, after using svg's converted from Android Drawable files.
The Problem is, that Skia is unable to parse the SVG Path. think something like the following would be a nice addition? (Currently don't got the time for an MR)
// Function: SKSvg.ReadElement(XElement e, Dictionary<string, string> style = null)
// between case "polygone" and "rect".
case "polyline":
// ... code above ...
if (!string.IsNullOrWhiteSpace(svgPath))
{
skPath1.Dispose();
if (skPath1 = SKPath.ParseSvgPathData(svgPath) is null) // <-- If skia is unable to parse the path, it returns null!
{
// Just as a hint for the frustrated developer...
this.LogOrThrow("Unsupported path in svg! You could try to combine and flatten it.");
break;
}
}
skPath1.FillType = SKSvg.ReadFillRule(style);
break;
case "rect":
// ... code below ...
Or should SkiaSharp fix the path reading?
The svg issue itself is better explained on this converter i found to fix the svg's. https://cursed-svg-fixer.glitch.me/
I am getting the following exception
System.Xml.XmlException: Reference to undeclared entity 'ns_extend'.
aswell.
Are there any news on this issue yet?
Or is there anything else I could do?
I can't really manipulate or change the svg files as they are coming from a customer's API.
However, after using this tool, the files are displayed correctly.