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

[Skia.Gtk] Skia is looking for files that don't exist on Arm64 #8296

Open
bstrother1 opened this issue Mar 10, 2022 · 9 comments
Open

[Skia.Gtk] Skia is looking for files that don't exist on Arm64 #8296

bstrother1 opened this issue Mar 10, 2022 · 9 comments
Labels
area/external Categorizes an issue or PR as being external to the Uno area/skia ✏️ Categorizes an issue or PR as relevant to Skia difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI platform/gtk Categorizes an issue or PR as relevant to GTK

Comments

@bstrother1
Copy link

Current behavior

Seems like a bug. Template Net 6 Gtk is looking for specific files that might not exist on a standard installation of gtk on an ARM64 mac.

Expected behavior

Gtk to build on an arm64 mac

How to reproduce it (as minimally and precisely as possible)

-> Have a Arm64/Monterey Mac Environment
-> Install gtk+3
-> attempt to run https://github.com/unoplatform/uno/discussions/8263#:~:text=dotnet%20App.Skia.Gtk.dll
-> get System.DllNotFoundException: libgtk-3-0.dll, libgtk.so.0, libgtk-3.0.dylib, gtk-3.dll

Workaround

n/a

Works on UWP/WinUI

Yes

Environment

Other

NuGet package version(s)

Latest Net6 template

Affected platforms

macOS, Skia (GTK on Linux/macOS/Windows)

IDE

Visual Studio 2022

IDE version

17.0.7303

Relevant plugins

No response

Anything else we need to know?

This was a discussion but it seems to be a bug relating to the fix for gtk on Monterey producing different files.

@bstrother1 bstrother1 added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Mar 10, 2022
@jeromelaban
Copy link
Member

Thanks for the report. Uno is not handling this part of the loading, and is likely a GtkSharp related issue.

@jeromelaban jeromelaban added area/external Categorizes an issue or PR as being external to the Uno and removed kind/bug Something isn't working labels Mar 10, 2022
@spouliot
Copy link
Contributor

spouliot commented Apr 15, 2022

@bstrother1 I ran into the same issue while following the getting started docs.

brew used to install stuff under /usr/local/ and GtkSharp still expect this.

https://github.com/GtkSharp/GtkSharp/blob/7995f132e19e18b8dae94359246540f059e53a86/Source/Libs/Shared/GLibrary.cs#L55

Adding DYLD_FALLBACK_LIBRARY_PATH inside my launch.json fixed this part.

      "env": {
        "DOTNET_MODIFIABLE_ASSEMBLIES": "debug",
        "DYLD_FALLBACK_LIBRARY_PATH": "/opt/homebrew/lib/"
      },

The next problem is that the native libSkiaSharp.dylib for a net5.0 project is only available as x86_64, not arm64

$ file bin/Debug/net5.0/runtimes/osx/native/libSkiaSharp.dylib                                                                                                                    bin/Debug/net5.0/runtimes/osx/native/libSkiaSharp.dylib: Mach-O universal binary with 1 architecture: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64
- Mach-O 64-bit dynamically linked shared library x86_64]
bin/Debug/net5.0/runtimes/osx/native/libSkiaSharp.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64

but since you mentioned using the net6 templates maybe you won't hit that similar issue.

GitHub
.NET wrapper for Gtk and other related libraries. Contribute to GtkSharp/GtkSharp development by creating an account on GitHub.

@jeromelaban
Copy link
Member

Indeed, SkiaSharp will need an arm64 build as well. One more thing to do for SkiaSharp :) It may be similar to mono/SkiaSharp#1829.

spouliot added a commit to spouliot/GtkSharp that referenced this issue Apr 17, 2022
…d gtk+3

brew used to install libraries under `/usr/local/` and GtkSharp still
expect this location.

https://github.com/GtkSharp/GtkSharp/blob/7995f132e19e18b8dae94359246540f059e53a86/Source/Libs/Shared/GLibrary.cs#L55

This fix will lookup the new library location `/opt/homebrew/lib/` if the
default ones (OS) or the `/usr/local/lib` could not load the libraries.

Reference: unoplatform/uno#8296 (comment)

Fixes GtkSharp#249
@spouliot
Copy link
Contributor

@jeromelaban SkiaSharp has an arm64 build, I used it recently for a console-based project. However it is (or was) only available in pre-release nugets. c.c. @mattleibow

Sadly the Skia version, checked at runtime, is different so you can't simply copy the newer fat binary as a quick workaround for Uno on macOS/M1 :-(

I have not found (honestly I did not look very hard) where the Uno.UI.Skia.Gtk nuget sources are located, but I suspect it would not be hard to fix.

@spouliot
Copy link
Contributor

Just FWI I hacked my local uno.ui.runtime.skia.gtk.nuspec to depend on the latest SkiaSharp preview available on nuget.org. Sadly there's no stable release that include the arm64 slice :(

<dependency id="SkiaSharp" version="2.88.0-preview.254" exclude="Build,Analyzers" />
<dependency id="SkiaSharp.NativeAssets.Linux" version="2.88.0-preview.254" exclude="Build,Analyzers" />

and I can now run the Gtk template/sample on my M1-based mac computer. YMMV

@bstrother1
Copy link
Author

Just FWI I hacked my local uno.ui.runtime.skia.gtk.nuspec to depend on the latest SkiaSharp preview available on nuget.org. Sadly there's no stable release that include the arm64 slice :(

<dependency id="SkiaSharp" version="2.88.0-preview.254" exclude="Build,Analyzers" />
<dependency id="SkiaSharp.NativeAssets.Linux" version="2.88.0-preview.254" exclude="Build,Analyzers" />

and I can now run the Gtk template/sample on my M1-based mac computer. YMMV

Where can I find this file? Thanks!

@spouliot
Copy link
Contributor

The exact location can vary depending on the Uno version you're using. Try the following command to locate it inside your nuget cache.

$ find ~/.nuget -name uno.ui.runtime.skia.gtk.nuspec

On my system the location returned is:

/Users/poupou/.nuget/packages/uno.ui.runtime.skia.gtk/4.1.9/uno.ui.runtime.skia.gtk.nuspec

Since I posted the workaround I noticed that the R(ed) and B(lue) channel seems inverted by Skia. That's likely something else that changed between the old 2.80 and the newer 2.88 release.

@jeromelaban
Copy link
Member

Indeed, we've noticed something like this depending on the platforms or OS configuration maybe. We're not definitely handling it properly.

@spouliot
Copy link
Contributor

depending on the platforms or OS configuration maybe

I lack a variety of platform to test, but it happens on my M1 mac. Since it's not realted t the original issue I filed a new issue for this problem: #8580

@jeromelaban jeromelaban added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Jun 16, 2022
@MartinZikmund MartinZikmund added difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI platform/gtk Categorizes an issue or PR as relevant to GTK and removed triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/external Categorizes an issue or PR as being external to the Uno area/skia ✏️ Categorizes an issue or PR as relevant to Skia difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI platform/gtk Categorizes an issue or PR as relevant to GTK
Projects
None yet
Development

No branches or pull requests

4 participants