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

[BUG] [net9.0] [Android15]The type initializer for 'SkiaSharp.SKImageInfo' threw an exception #3094

Closed
1 task done
maonaoda opened this issue Dec 3, 2024 · 4 comments
Closed
1 task done
Labels

Comments

@maonaoda
Copy link

maonaoda commented Dec 3, 2024

Description

Unable to launch page that uses SkiaSharp.

build output

 *  Executing task: dotnet build /Users/xxx/Projects/Practice/SkiaSharpSample/SkiaSharpSample.csproj -p:Configuration=Debug -p:TargetFramework=net9.0-android -p:AndroidSdkDirectory=/Users/xxx/Library/Developer/Xamarin/android-sdk-macosx 

load .zprofile complete
  SkiaSharpSample net9.0-android succeeded with 1 warning(s) (31.3s) → bin/Debug/net9.0-android/SkiaSharpSample.dll
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.7/tools/Xamarin.Android.Common.targets(2192,2): warning XA0141: NuGet package 'SkiaSharp.NativeAssets.Android' version '3.118.0-preview.1.2' contains a shared library 'libSkiaSharp.so' which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details

Build succeeded with 1 warning(s) in 31.6s
 *  Terminal will be reused by tasks, press any key to close it. 

Emulator info
image
image

Exception:

F/mono-rt : [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
F/mono-rt :  ---> System.DllNotFoundException: libSkiaSharp
F/mono-rt :    at SkiaSharp.SKImageInfo..cctor() in /_/binding/SkiaSharp/SKImageInfo.cs:line 48
F/mono-rt :    --- End of inner exception stack trace ---
F/mono-rt :    at SkiaSharp.Views.Android.SurfaceFactory.CreateInfo(Int32 width, Int32 height) in /_/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Android/SurfaceFactory.cs:line 90
F/mono-rt :    at SkiaSharp.Views.Android.SurfaceFactory.UpdateCanvasSize(Int32 w, Int32 h, Single density) in /_/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Android/SurfaceFactory.cs:line 23
F/mono-rt :    at SkiaSharp.Views.Android.SKCanvasView.set_IgnorePixelScaling(Boolean value) in /_/source/SkiaSharp.Views/SkiaSharp.Views/Platform/Android/SKCanvasView.cs:line 72
F/mono-rt :    at SkiaSharp.Views.Maui.Handlers.SKCanvasViewHandler.MapIgnorePixelScaling(SKCanvasViewHandler handler, ISKCanvasView canvasView) in /_/source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Core/Handlers/SKCanvasView/SKCanvasViewHandler.Android.cs:line 42
F/mono-rt :    at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[SkiaSharp.Views.Maui.ISKCanvasView, SkiaSharp.Views.Maui.Core, Version=3.118.0.0, Culture=neutral, PublicKeyToken=null],[SkiaSharp.Views.Maui.Handlers.SKCanvasViewHandler, SkiaSharp.Views.Maui.Core, Version=3.118.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in /_/src/Core/src/PropertyMapper.cs:line 172
F/mono-rt :    at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in /_/src/Core/src/PropertyMapper.cs:line 47
F/mono-rt :    at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in /_/src/Core/src/PropertyMapper.cs:line 82
F/mono-rt :    at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in /_/src/Core/src/Handlers/Element/ElementHandler.cs:line 79
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler`2[[SkiaSharp.Views.Maui.ISKCanvasView, SkiaSharp.Views.Maui.Core, Version=3.118.0.0, Culture=neutral, PublicKeyToken=null],[SkiaSharp.Views.Android.SKCanvasView, SkiaSharp.Views.Android, Version=3.118.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756]].SetVirtualView(IView view) in /_/src/Core/src/Handlers/View/ViewHandlerOfT.cs:line 53
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler`2[[SkiaSharp.Views.Maui.ISKCanvasView, SkiaSharp.Views.Maui.Core, Version=3.118.0.0, Culture=neutral, PublicKeyToken=null],[SkiaSharp.Views.Android.SKCanvasView, SkiaSharp.Views.Android, Version=3.118.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756]].SetVirtualView(IElement view) in /_/src/Core/src/Handlers/View/ViewHandlerOfT.cs:line 56
F/mono-rt :    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in /_/src/Controls/src/Core/Element/Element.cs:line 1027
F/mono-rt :    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in /_/src/Controls/src/Core/Element/Element.cs:line 969
F/mono-rt :    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in /_/src/Controls/src/Core/VisualElement/VisualElement.cs:line 2138
F/mono-rt :    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in /_/src/Core/src/Platform/ElementExtensions.cs:line 96
F/mono-rt :    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in /_/src/Core/src/Platform/ElementExtensions.cs:line 127
F/mono-rt :    at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in /_/src/Core/src/Handlers/Layout/LayoutHandler.Android.cs:line 41
F/mono-rt :    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in /_/src/Core/src/Handlers/View/ViewHandlerOfT.cs:line 56
F/mono-rt :    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in /_/src/Controls/src/Core/Element/Element.cs:line 1027
F/mono-rt :    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in /_/src/Controls/src/Core/Element/Element.cs:line 969
F/mono-rt :    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in /_/src/Controls/src/Core/VisualElement/VisualElement.cs:line 2138
F/mono-rt :    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in /_/src/Core/src/Platform/ElementExtensions.cs:line 96
F/mono-rt :    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in /_/src/Core/src/Platform/ElementExtensions.cs:line 127
F/mono-rt :    at Microsoft.Maui.Handlers.ScrollViewHandler.UpdateInsetView(IScrollView scrollView, IScrollViewHandler handler, ICrossPlatformLayout crossPlatformLayout) in /_/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs:line 186

image

Code

https://github.com/maonaoda/SkiaSharpBug

Expected Behavior

Do not crash

Actual Behavior

Crash

Version of SkiaSharp

3.118.0-preview.1 (Next Preview)

Last Known Good Version of SkiaSharp

not sure

IDE / Editor

Visual Studio Code (macOS)

Platform / Operating System

Android

Platform / Operating System Version

Android15

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@IngweLand
Copy link

Same with Blazor, on branch release/3.116.0

@mattleibow
Copy link
Contributor

This was just fixed in #3096

Duplicate of #3025

A new stable version was also just released.

Thanks for reporting with all the details.

@github-project-automation github-project-automation bot moved this from New to Done in SkiaSharp Backlog Dec 6, 2024
@maonaoda
Copy link
Author

maonaoda commented Dec 6, 2024

@mattleibow
For 3.116.1, I was able to use net9.0-android, thanks!
but I couldn't start net8.0-android. I don't care about net8.0-android right now, but I wanted to share this with you.

@mattleibow
Copy link
Contributor

Oh... Thanks for letting me know, I'll check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

3 participants