Git Product home page Git Product logo

Comments (6)

wieslawsoltes avatar wieslawsoltes commented on July 17, 2024

Can you try using normal file (not an embedded resource) as check if it works?

from svg.skia.

SeRgI1982 avatar SeRgI1982 commented on July 17, 2024

In my production case, I download a whole data from my server, so my SVG is in string property of my Model. I will try to download it, save as file and load using path.

from svg.skia.

SeRgI1982 avatar SeRgI1982 commented on July 17, 2024

Ok, I have changed this sample project and currently, embedded resources are saved to device.
SKPicture is loaded via fila path and I would say that it is even worst:

  • the same exception +

System.NullReferenceException: Object reference not set to an instance of an object.
at Svg.SvgDocument.Open[T] (System.String path, System.Collections.Generic.Dictionary`2[TKey,TValue] entities) [0x00035] in D:\a\1\s\externals\SVG\Source\SvgDocument.cs:304
at Svg.Skia.SKSvg.OpenSvg (System.String path) [0x00000] in D:\a\1\s\src\Svg.Skia\SKSvg.cs:127
at Svg.Skia.SKSvg.Open (System.String path) [0x00006] in D:\a\1\s\src\Svg.Skia\SKSvg.cs:156
at Svg.Skia.SKSvg.Load (System.String path) [0x00006] in D:\a\1\s\src\Svg.Skia\SKSvg.cs:181
at SvgTest.MainPage.LoadImage (SvgTest.Item item) [0x0001e] in /Users/DevGroup/Projects/SvgTest/SvgTest/MainPage.xaml.cs:143

  • sometimes a Native exception appears

Tested on iOS/Android (simulator and real device)

Additionally, I have tested function SKSvg.FromSvg(string svgContent) but I have got the same issues.
It looks like the problem lives in your one dependency library - Svg

Are you able to help with this ?

SvgTest.zip

from svg.skia.

wieslawsoltes avatar wieslawsoltes commented on July 17, 2024

@SeRgI1982 I have problem on my machine to run Xamarin.Forms android to debug the issues specific to android. I can not test on iOS at all.

Can you try stepping through the Svg.Skia code and find where the exception is originating?

from svg.skia.

SeRgI1982 avatar SeRgI1982 commented on July 17, 2024

The same achieved on your sample

{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Svg.SvgElement' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Drawing.Text.FontCollection..ctor () [0x00006] in :0
at System.Drawing.Text.PrivateFontCollection..ctor () [0x00000] in :0
at Svg.SvgElement..cctor () [0x0000a] in /Users/DevGroup/Svg.Skia/externals/SVG/Source/SvgElementStyle.cs:473
--- End of inner exception stack trace ---
at Svg.SvgFragment..ctor () [0x00010] in /Users/DevGroup/Svg.Skia/externals/SVG/Source/Document Structure/SvgFragment.cs:15
at Svg.SvgDocument..ctor () [0x00007] in /Users/DevGroup/Svg.Skia/externals/SVG/Source/SvgDocument.cs:94
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:936
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:944
at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic, System.Boolean wrapExceptions) [0x00095] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/ReferenceSources/RuntimeType.cs:185
at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean wrapExceptions, System.Boolean skipCheckThis, System.Boolean fillCache) [0x00009] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/ReferenceSources/RuntimeType.cs:155
at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Boolean wrapExceptions, System.Threading.StackCrawlMark& stackMark) [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/rttype.cs:5770
at System.Activator.CreateInstance[T] () [0x00029] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/activator.cs:236
at Svg.SvgElementFactory.CreateElement[T] (System.Xml.XmlReader reader, System.Boolean fragmentIsDocument, Svg.SvgDocument document) [0x0003e] in /Users/DevGroup/Svg.Skia/externals/SVG/Source/SvgElementFactory.cs:93
at Svg.SvgElementFactory.CreateDocument[T] (System.Xml.XmlReader reader) [0x00035] in /Users/DevGroup/Svg.Skia/externals/SVG/Source/SvgElementFactory.cs:62
at Svg.SvgDocument.Open[T] (System.Xml.XmlReader reader) [0x000a0] in /Users/DevGroup/Svg.Skia/externals/SVG/Source/SvgDocument.cs:395 }

PrivateFontCollection constructor calls

GDIPlus.CheckStatus (GDIPlus.GdipNewPrivateFontCollection (out _nativeFontCollection));

I guess that something is wrong here.

from svg.skia.

wieslawsoltes avatar wieslawsoltes commented on July 17, 2024

@SeRgI1982 Seems like issue with some missing functionality from System.Drawing on Android/iOS. trying to fix this svg-net/SVG#711

I will publish patched version of SVG with Svg.Skia that includes this fix in version 0.1.8.

from svg.skia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.