luberda-molinet / FFImageLoading

Image loading, caching & transforming library for Xamarin and Windows
MIT License
1.42k stars 377 forks source link

Error while loading SVG #1449

Open VictorKochetkov opened 4 years ago

VictorKochetkov commented 4 years ago

Description Getting exception in output when showing SVG:

<forms:SvgCachedImage WidthRequest="400" HeightRequest="400" Source="resource://Countries.Forms.Assets.countries_background_pattern.svg"/>
System.NullReferenceException: Object reference not set to an instance of an object.
at FFImageLoading.Svg.Platform.SKSvg.ReadElement (System.Xml.Linq.XElement e, System.Collections.Generic.Dictionary`2[TKey,TValue] style) [0x0022e] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:558 
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) [0x006d7] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:343 
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) [0x007f4] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SkSvg.cs:396 
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

SVG file countries_background_pattern.zip

Basic Information Xamarin.FFImageLoading.Svg.Forms 2.4.11.982

Alextorres950325 commented 4 years ago

same error here and some svg showing invisible

felipeapj commented 4 years ago

I always process my svg before use in projects with FFImageLoading. Just use this https://jakearchibald.github.io/svgomg/, its recommended by the author. In options, disable all "Round/Rewrite" options and "Style to attbributes".