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.45k stars 539 forks source link

[BUG] Website using SkiaSharp does not launch anymore after upgrade from 1.68 to 2.80.1, due to a signature problem with OpenTK.GLControl #1479

Closed MathieuJack closed 4 years ago

MathieuJack commented 4 years ago

Description

I have a Asp.Net MVC Project that is referencing nugets SkiaSharp and SkiaSharp.Views.Forms I have updated these Nugets 1.68 -> 2.80.1 Since this update, website can't start and displays this error :

Could not load file or assembly 'OpenTK.GLControl' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

Code

(no snippet)

Expected Behavior

Website should run OK after upgrading to latest version of Skia#

Actual Behavior

Website can't start and upper error is displayed in html

Basic Information

Detailed IDE/OS information (click to expand) Microsoft Visual Studio Enterprise 2019 Preview Version 16.8.0 Preview 1.0 VisualStudio.16.Preview/16.8.0-pre.1.0+30404.54 Microsoft .NET Framework Version 4.8.03752 Installed Version: Enterprise Visual C++ 2019 00433-90100-10153-AA240 Microsoft Visual C++ 2019 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASA Service Provider 1.0 ASP.NET and Web Tools 2019 16.8.117.38827 ASP.NET and Web Tools 2019 ASP.NET Core Razor Language Services 16.1.0.2037701+cd85e360366b379efba8df5b3d4c22c90d273622 Provides languages services for ASP.NET Core Razor. ASP.NET Web Frameworks and Tools 2019 16.8.117.38827 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 16.8.117.38827 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.4.6000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 16.8.117.38827 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.4.6000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 3.8.0-1.20378.6+226c0c3f392232b3dd7ecd527f1fd00f0f86d7e4 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events GitHub.VisualStudio 2.11.102.28613 A Visual Studio Extension that brings the GitHub Flow into Visual Studio. IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info Microsoft Azure HDInsight Azure Node 2.4.6000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.4.6000.0 Language service for Hive query Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio Microsoft Azure Stream Analytics Language Service 2.4.6000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30701.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.1.79+ge3567815aa.RR Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio 16.8.0 (bce9320) Support for debugging Mono processes with Visual Studio. NuGet Package Manager 5.8.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info SQL Server Data Tools 16.0.62007.23150 Microsoft SQL Server Data Tools Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory. Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory. ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 16.0.20722.2003 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.8.0-1.20378.6+226c0c3f392232b3dd7ecd527f1fd00f0f86d7e4 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 11.0.0.0 for F# 5.0 16.8.0-beta.20367.6+66042d33b998a180edbd99af6064da85f8977bf3 Microsoft Visual F# Tools 11.0.0.0 for F# 5.0 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio. Visual Studio Tools for CMake 1.0 Visual Studio Tools for CMake Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Foo 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.8.000.52 (master@587f555) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.8.0.167 (remotes/origin/d16-8@d9d45ae09) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.8.81 (4121183) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 11.0.99.9 (d16-8/2bd5c33) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 83105ba Java.Interop: xamarin/java.interop/d16-8@8f217e7 ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc Xamarin.iOS and Xamarin.Mac SDK 13.22.1.3 (914cdaa26) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Here is full error page:

Server Error in '/' Application.
Could not load file or assembly 'OpenTK.GLControl' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'OpenTK.GLControl' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'OpenTK.GLControl' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = OpenTK.GLControl
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: OpenTK.GLControl | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/KODE/YADUSURF-GIT/Meteo Surf Project/Yadusurf.Website.MVC2013/
LOG: Initial PrivatePath = C:\KODE\YADUSURF-GIT\Meteo Surf Project\Yadusurf.Website.MVC2013\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\KODE\YADUSURF-GIT\Meteo Surf Project\Yadusurf.Website.MVC2013\web.config
LOG: Using host configuration file: C:\Users\mathieu\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/mathieu/AppData/Local/Temp/Temporary ASP.NET Files/vs/55705c4e/9cc63ba0/OpenTK.GLControl.DLL.
LOG: Attempting download of new URL file:///C:/Users/mathieu/AppData/Local/Temp/Temporary ASP.NET Files/vs/55705c4e/9cc63ba0/OpenTK.GLControl/OpenTK.GLControl.DLL.
LOG: Attempting download of new URL file:///C:/KODE/YADUSURF-GIT/Meteo Surf Project/Yadusurf.Website.MVC2013/bin/OpenTK.GLControl.DLL.
LOG: Using application configuration file: C:\KODE\YADUSURF-GIT\Meteo Surf Project\Yadusurf.Website.MVC2013\web.config
LOG: Using host configuration file: C:\Users\mathieu\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: OpenTK.GLControl, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4
ERR: Failed to complete setup of assembly (hr = 0x80131045). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'OpenTK.GLControl' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]

[FileLoadException: Could not load file or assembly 'OpenTK.GLControl, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +37
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +159
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +80
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +29
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +39

[ConfigurationErrorsException: Could not load file or assembly 'OpenTK.GLControl, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +777
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +229
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +140
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +176
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +99
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +310
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +165
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +590

[HttpException (0x80004005): Could not load file or assembly 'OpenTK.GLControl, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10080656
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0
mattleibow commented 4 years ago

Thanks for reporting this...

Not quite sure what is going on yet, but there appears to be some issue with the OpenTK packages... It appears to be strong named... but for some reason that is not a valid signature.

However, it appears to be fixed in the next update of OpenTK. Could you try updating to 3.1.0 and that should fix it.

I'll fix this in SkiaSharp buy using the fixed version.

MathieuJack commented 4 years ago

Matt, updating OpenTK.GLControl (and OpenTK) nugets indeed solved the signature problem.

Another issue appeared next to this one. Now, Website is "launched", ie it enters the c# code. But now, as soon as execution hits first call to native Skia# code, a System.TypeInitializationException is raised. More precisely, this line of code : SKBitmap.Decode(stream);

Exception says : System.TypeInitializationException: 'The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception.' Inner exception : DllNotFoundException: Unable to load library 'libSkiaSharp'.

Indeed, website bin folder does not contain LibSkiaSharp.dll, but only a libSkiaSharp.dylib I tried to copy myself a libSkiaSharp.dll (found in a win-x86 folder), but I got same result.

mattleibow commented 4 years ago

That might be #1393... Do you have SkiaSharp installed into the actual web app, or just a dependency?

I just pushed a new preview to NuGet that should have this fixed. I am hoping to release that to stable once I finish up the docs and such.

MathieuJack commented 4 years ago

Skia# nuget is installed into the web app project, yes. And also in several referenced projects. There is a strange thing I notice : all my prpjects referencing Skia# nuget show this strange reference (reference with a warning icon, and with a long path on my disk that ends with libskiasharp.dyi; but this file does not exist) see this image : https://ibb.co/gzwgjst It appeared I think when I upgraded from 1.68 to 2.80.1

I updated to skia# preview, but for some other reason it does not compile. Error is : error : Unable to parse version value '2.80.2-preview.33' from 'packages.config'.

mattleibow commented 4 years ago

The warning in the references is a bug in the IDE: https://developercommunity.visualstudio.com/content/problem/1142283/elements-still-appear-in-the-ide-even-though-they.html

I'm not sure why you are getting that version parsing error, mine updated fine. I am using the stable version:

Microsoft Visual Studio Enterprise 2019
Version 16.7.2

and on my internal preview:

Microsoft Visual Studio Enterprise 2019 Int Preview
Version 16.8.0 Preview 2.0 [30407.236.master]

With regards to the exception... I think that is a bug in my code. I'll repoen and fix. Thanks for reporting this. I think this is the way IIS handles app domains.

mattleibow commented 4 years ago

I have a PR building that should fix this. Thanks for reporting.

https://github.com/mono/SkiaSharp/pull/1483

mattleibow commented 4 years ago

@MathieuJack it should be up on the preview feed as v2.80.2-pr.1483.6.

Let me know how it goes and I'll merge and push out a new preview.

MathieuJack commented 4 years ago

I could build with 2.80.2-preview.33 Still have exception with this version : System.TypeInitializationException: 'The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception.' Inner exception : DllNotFoundException: Unable to load library 'libSkiaSharp'.

I don't know how to get & use v2.80.2-pr.1483.6 in #1481 As @jsgoupil suggests, could you publish this change to preview? Thanks!

mattleibow commented 4 years ago

Just pushed out v2.80.2-preview.36 to NuGet.org. Let me know if that works for you.

Apologies for the long delay, CI was not playing nice at all.

MathieuJack commented 4 years ago

I have tested my web app with v2.80.2-preview.36, and it is working. Good job! Thank you.

mattleibow commented 4 years ago

Awesome! I think this is the last issue I found with the new packaging. If all goes well until next week-ish, then I'll push out the next stable.

Thanks for the issues, the feedback and all the rest!