mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.54k stars 543 forks source link

[BUG] Unity Editor can’t find dependency DLLs in subfolders anymore (DLLNotFoundException) #3016

Closed SashelI closed 2 months ago

SashelI commented 2 months ago

Description

Hi,

I came into some frustrating issue today in the editor : I have a project in which I have manually imported libraries. All of the required dependencies are also in the project, in a subfolder (see screenshots below).

This project was working fine and finding everything it needed. Today I downloaded the new version of the libraries (from skiasharp 2.88.7 to skiasharp 2.88.8), replaced DLLs without changing any of the folder structure, and suddendly, with two different libraries (libSkiaSharp and pdfium from SkiaSharp and PDFToImage), when I hit play i have a “DLLNotFoundException” on the dependencies, but only if they are in a subfolder…

I have many dlls and .so because this is a cross-platform project (android ARM64 + android x64 + UWP ARM64 + Winx64), so putting every single dependency dll in the same folder is a no-go.

Anyone knows why this happens ? Thanks.

Here are the screenshots :

Working old project structure, this exact same structure on the updated dlls doesn’t work, and I have to put libskiasharp.dll in the root Skia folder :

image image

(And same goes for pdfium.dll)

Code

https://github.com/SashelI/skiadll-tests-unity

Expected Behavior

No response

Actual Behavior

DllNotFoundException: libSkiaSharp assembly:<unknown assembly> type:<unknown type> member:(null) SkiaSharp.SKImageInfo..cctor () (at <ba5db125678d4cb8bfb461a6f3fca1c2>:0) Rethrow as TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.

Version of SkiaSharp

Other (Please indicate in the description)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Other (Please indicate in the description)

Platform / Operating System

Windows

Platform / Operating System Version

Windows 10 x64

Devices

No response

Relevant Screenshots

image image

Relevant Log Output

`DllNotFoundException: libSkiaSharp assembly:<unknown assembly> type:<unknown type> member:(null)
SkiaSharp.SKImageInfo..cctor () (at <ba5db125678d4cb8bfb461a6f3fca1c2>:0)
Rethrow as TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.`

Code of Conduct

SashelI commented 2 months ago

Update : the issue is even weirder : it actually can’t find the dll anywhere on each project startup until I move the dll file to a different folder ?? But no matter the folder :

I have my dll in a Skia/win-64/native subfolder. I open the Unity project, click play : DLLNotFound I ctrl+x the dll, put it in Skia/ folder. hit play, it works I close the editor I open the Unity project again I hit play : DLLNotFound I ctrl+x the dll, put it in Skia/win-64/native subfolder Hit play, it works What ?

Here is a repo with the issue on it, if anyone wants to give it a try : https://github.com/SashelI/skiadll-tests-unity