sandrohanea / whisper.net

Whisper.net. Speech to text made simple using Whisper Models
MIT License
589 stars 90 forks source link

MAUI - MacCatalyst Codesign fails - "unsealed contents present in the bundle root" #212

Open tonyedwardspz opened 3 months ago

tonyedwardspz commented 3 months ago

When using 1.5.0, Codesign fails during the building of a MAUI MacCatalyst app with the following error.

Codesign failed: unsealed contents present in the bundle root

This is linked to the metal file that is copied over by this library during the build.

This is wholely related to the way that Mac (and presumably iOS etc) apps are required to be packaged. It's by no means unique to Whisper.Net. Here's a related Overflow post with a list of variations on the theme.

Downgrading to 1.4.7 fixes the issue, but comes with significant performance loss compared to metal enabled 1.5.0. I suspect that this commit could be broadly connected to this or something similar. It'd be brilliant to use metal in MAUI mac apps on arm64 chips. The prototype console app with 1.5.0 was blisteringly fast!

Is there any way to control where the metal file get's placed during build? Ideally, it would end up in /Resources/Raw for a MAUI project. Nothing jumped out after a poke around the Library, but I could have easily missed it.

If not, is this something that could be added / addressed in a future release?

Thanks for all the effort with the library. 🙏 It's been super useful.

tonyedwardspz commented 3 months ago

I've gotten around the above problem by omitting the Runtime package,instead manually including the files and moving them around as part of the build. It looks like it'll work!

However. . .

I'm now getting a bunch of logs similar to this:

warning: object file (/usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64/8.0.6/runtimes/maccatalyst-arm64/native/libicudata.a(stubdata.ao)) was built for newer Mac Catalyst version (14.2) than being linked (14.0)

Appreciating that this isn't a Whisper.net issue, I wondered if anyone could point me in the right direction to get past this warning.

sandrohanea commented 1 month ago

Thank you @tonyedwardspz for these details. Unfortunately I don't have a macbook anymore and I am not able to test the library for mac. The build artefacts are created using the github action: https://github.com/sandrohanea/whisper.net/actions/workflows/macos-native-build.yaml

I am curious exactly which files did you include manually in your project?

Did you include both libwhisper.dylib and ggml-metal.metal ?

Now (starting with 1.7.0) a new dylib is required libggml.dylib and libwhisper.dylib have a dependency on this.

I can change the library to outuput the ggml-metal.metal into /Resources/Raw` for ios and maccatalyst apps if that would help.

tonyedwardspz commented 1 month ago

Thanks for the reply.

Both initially, but I dropped the metal file after a rebuild. I downgraded to 1.4.7 (I think) eventually and it was fine after the rebuild.

I'm planning to try the new release when I get a chance. I'll take better notes and report back 👍

Thanks for all your work on this. Awesome project, and I learned a bunch getting things working🙏