-
Notifications
You must be signed in to change notification settings - Fork 546
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
Function pointers and LibraryImport #2917
Function pointers and LibraryImport #2917
Conversation
YES! |
So far this:
|
The device failures are because all my certs just expired. The other test failures are the fact that the main branch is read and cannot pull assets. I have updated certs and re-triggered a full build. The compile will still fail for windows I think, but the devices may run. Not 10% sure as I think there may be some bad conditionals somewhere causing the error. |
The device tests should be running for iOS, Android and macOS for .NET 7, so we shall see. I do need to add .NET 8 but I will do that once this is merged. |
Thanks. Pushed another commit that should fix tizen build. EvasGlApi+reflection probably could be replaced with a |
Also updated remaining main interop projects for consistency: SkiaSharp.Resources, SkiaSharp.SceneGraph, SkiaSharp.Skottie. Didn't touch |
@mattleibow tests are failing, but I am a bit confused why.
But I tripple checked, and sk_rtree_factory_new is correctly defined in LibraryImport/DllImport, as well as referenced skia submodule has this method included. |
as part of the build I check to see if the native things have changed and then download the previous native binaries. However, the last few builds on main never finished. I triggered them so should work now. Let me retry. |
@mattleibow side question, but what frameworks does skia sharp still supports? Especially from Mono world. |
The old mono/mono (along with Xamarin.iOS/Xamarin.Android) went out of support earlier this year. I doubt there's any point in wasting more time on it. If someone uses the unsupported framework they can stick to older SkiaSharp release. |
Another problem is DisableRuntimeMarshalling, which also makes it easier to marshal bools in function pointers. Since DisableRuntimeMarshalling is not supported in .NET Framework, I don't think I can use function pointers without replacing all booleans with bytes or something. |
We can do this in the generator... I usually add a internal static extern sk_maskfilter_t sk_maskfilter_new_blur_with_flags (SKBlurStyle param0, Single sigma, [MarshalAs (UnmanagedType.I1)] bool respectCTM); |
Either way it should work with netframework, since it's just a source code generation, nothing different in runtime. |
@mattleibow just pushed a commit moving all the #if #else from DelegateProxy files to auto generated code. I reused the same generator tool for now just by extending it. This way almost all the boilerplate is hidden behind generated code. |
Yeah, much smarter... Writing a source generator to generate source for generated sources... At this point am I thinking like AI. |
…InternalsVisibleTo configured
@mattleibow hi!
Hopefully CI should pass now. |
…n .NET 7+ build, see comments
16b81ad
to
53e445e
Compare
After much thrashing on CI just to get a green main branch, I see we now have some failing tests that are related to this PR. I think it is just these 2 really: The first one is interesting be cause it can't find
The second failure is probably because you are skipping the tests in the .Console project but it also needs to be in the .Devices project. |
@maxkatz6 I think this PR is good, just the 2 failures. One is a missing condition/define in the .Devices project and then the other is the auto-naming of p/invokes based on Charset that I am not sure has a direct parallel, but maybe setting the string marshalling or just using the |
The distinction of Modern .NET has NativeLibrary.Load but I guess that may not be applicable here if the tests still run on .NET Framework. |
I need to check that these new things are not slower: dotnet/runtime#106491 Might be unrelated, but might be related to usage of new things. Has anyone done any perf benchmarks on any platforms? I will try set up something, but if anyone has a complex app that draws a bunch of things it would be great if you ran a check and got a speedscope: https://github.com/dotnet/maui/wiki/Profiling-.NET-MAUI-Apps I suppose a test would be:
|
Co-authored-by: Filip Navara <[email protected]>
@mattleibow both tests should be fixed now. I can run our control catalog on my iOS device later this week. |
Woohoo! This is finally green and finally good to go. Merged and now time for that ! Thanks so much for this! This has been on the list since net7.0 started doing cool things. |
Description of Change
This PR is pretty big. If necessary, I can split HarfBuzz and Skia changes on two PRs. In theory, generated code can be be extracted into a separated PR as well, since all changes should be under conditional compilation.
What was changed step by step:
DelegateProxies.Create<T>
usage was replaced without generics.bool
as 1 byte, and function pointers by default marshal it as 4 bytes, I had to disable runtime marshalling. This change required to replace remaining DllImports with LibraryImport as well. As a bonus - final app size should be smaller without runtime marshalling (assuming other dependencies don't use it too).Note:
void*
instead of full function pointer, but it doesn't seem to cause other issuesBugs Fixed
Not sure if this PR fixed them, or some another, but these two issues are not reproducible anymore:
API Changes
None. Unless I missed any.
Behavioral Changes
None. Hopefully.
Required skia PR
None.
PR Checklist