-
Notifications
You must be signed in to change notification settings - Fork 344
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
[mobile] Move to net8 MAUI and add MacCatalyst support #406
base: main
Are you sure you want to change the base?
Conversation
Right now we are hitting this on Catalyst
I have talked with @YUNQIUGUO and we identified the issue , we need to update the |
Update: We identified the issue that for this to work, the onnxruntime_extensions.xcframework requires catalyst build support to be added as well. And with that supported, @rmarinho helped verify with a Nuget ORT package contains catalyst support and Nuget ORT Extension package with catalyst support (manually replaced and tested for now), this .NET MAUI app works in MacCatalyst platform. So next step is when the official/dev version dummy extensions nuget package is released, we can update the package dependency here in this project and should be good to go. |
Yap sounds good . will wait for dev package |
dc1c61c
to
da455a2
Compare
Hello, I just tested the sample with the latest version of the onxx runtime and seems to be working fine, can we merge this? Thanks |
@YUNQIUGUO do you think this can be merged? |
@rmarinho & @YUNQIUGUO With the latest prerelease version "0.11.0-dev-20240524-2333-8d8670f7" of "Microsoft.ML.OnnxRuntime.Extensions", I was able to run the "MAUISuperResolution" perfectly fine for the Android target and also all fine in the iOS-Simulator. But when running the same code with MacCatalyst x64 target, I get an runtime error at inference time: [ErrorCode:Fail] Fatal error: com.microsoft.extensions:DecodeImage(-1) is not a registered function/op In contrast to the "MauiVisionSample" which does NOT use a pre-/postprocessing pipeline in the ONNX model, the "MauiSuperResolution" sample DOES USE and need the Extensions support for custom pre-/post processing like DecodeImage() and EncodeImage() Vision Operators:
But even as the code in "MauiSuperResolution" registers for the Runtime Extensions support with following code in "OrtInferenceSession.cs":
that ORT extensions are only found at runtime for Android and iOS, but NOT for MacCatalyst-x64. I checked the "bin/debug/net8-maccatalyst/maccatalyst-x64" directory, and there is a "onyxruntime_extensions" Unix Executable File, but somehow that is not found at runtime or it is the wrong version for maccatalyst-x64. So I think it is not sufficient to test ORT Extensions support or .NET8 support with the "MauiVisionSample", which only needs the Dummy Extensions. The test should be done with "MauiSuperResolution", which DOES use (and need) the ONNX Runtime Extensions. The latest "0.11.0-dev-20240524-2333-8d8670f7" nugget package of "Microsoft.ML.OnnxRuntime.Extensions" now allows to compile without error against the "net8.0-maccatalyst" target, but it can not find the standard ONNX Runtime Extensions functions/ops at runtime at inference time. Verified with: MauiSuperResolution.csproj::
|
The latest release of the extensions package should now have a mac-catalyst build. https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.Extensions/0.12.0 |
mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MauiVisionSample.csproj
Outdated
Show resolved
Hide resolved
5308275
to
74cd88f
Compare
yap I updated all packages and I also hit that error on MacCatalyst on MBP M3 using the MAUISuperResolution" wi I do think we can merge this pr as it fixes and updates most for net8
|
@skottmckay and @rmarinho Now with version 0.12 the error changed to "One or more errors occurred. (The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.)". With v 0.11-dev it was another error I send here before/above. So with your example of the "Dummy" package it may be possible now to built for MacCatalyst, but when you actually use ORT-Extension v0.12 it does NOT work on MacCatalyst. |
Update onxx runtime Update maui super resolution Add default sln Add Catalyst platform to super resolution Update versions
87a2bbd
to
d49ffd7
Compare
Unfortunately the build config for mac-catalyst is excluding the image decoding/encoding operators due to an issue with opencv. This PR should hopefully address that. |
Any else I need to do to get this merged? Thanks |
@skottmckay so basically your mentioned PR only is a different wording for a clearer error message like "NSImage is not supported on Mac Catalyst", but the image decoding/encoding operators will NOT be included for Mac Catalyst? Is there no hope that this issue with opencv can be fixed for Mac Catalyst? |
This pull request primarily aims to update the MauiVisionSample project in the
mobile/examples/Maui
directory to support the MacCatalyst platform, along with some other improvements and updates. The most significant changes include updating the target frameworks in the project file, adding MacCatalyst-specific files, updating package references, and adding debug logging.This pull request primarily focuses on updating the MauiVisionSample application to support the MacCatalyst platform and updating the target frameworks to .NET 8.0. It also includes changes to improve debugging, and package updates.
The most important changes are:
This pull request includes several changes to enhance compatibility with .NET 8.0, add support for MacCatalyst, and update dependencies in the MauiVisionSample and MauiSuperResolution projects.
Compatibility and Platform Support:
mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MainPage.xaml.cs
)mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MauiVisionSample.csproj
) [1] [2] [3]mobile/examples/super_resolution/MAUI/MauiSuperResolution/MauiSuperResolution.csproj
) [1] [2]Dependency Updates:
Microsoft.ML.OnnxRuntime
,SkiaSharp
, and added new references forMicrosoft.Maui.Controls
andMicrosoft.Extensions.Logging.Debug
. (mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MauiVisionSample.csproj
)Microsoft.ML.OnnxRuntime
and its extensions. (mobile/examples/super_resolution/MAUI/MauiSuperResolution/MauiSuperResolution.csproj
)Logging and Debugging:
mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MauiProgram.cs
)MacCatalyst Specific Files:
AppDelegate.cs
,Entitlements.plist
,Info.plist
, andProgram.cs
for both projects.mobile/examples/Maui/MauiVisionSample/MauiVisionSample/Platforms/MacCatalyst/AppDelegate.cs
) [1] (mobile/examples/Maui/MauiVisionSample/MauiVisionSample/Platforms/MacCatalyst/Entitlements.plist
) [2] (mobile/examples/Maui/MauiVisionSample/MauiVisionSample/Platforms/MacCatalyst/Info.plist
) [3] (mobile/examples/Maui/MauiVisionSample/MauiVisionSample/Platforms/MacCatalyst/Program.cs
) [4]mobile/examples/super_resolution/MAUI/MauiSuperResolution/Platforms/MacCatalyst/AppDelegate.cs
) [1] (mobile/examples/super_resolution/MAUI/MauiSuperResolution/Platforms/MacCatalyst/Entitlements.plist
) [2] (mobile/examples/super_resolution/MAUI/MauiSuperResolution/Platforms/MacCatalyst/Info.plist
) [3] (mobile/examples/super_resolution/MAUI/MauiSuperResolution/Platforms/MacCatalyst/Program.cs
) [4]Solution Files:
mobile/examples/Maui/MauiVisionSample/MauiVisionSample/MauiVisionSample.sln
)mobile/examples/super_resolution/MAUI/MauiSuperResolution/MauiSuperResolution.sln
)