[.NET/AudioUnit] Use [UnmanagedCallersOnly] instead of [MonoPInvokeCallback] Partial Fix for #10470 - #15808
Conversation
…llback] Partial Fix for dotnet#10470
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| foreach (RenderDelegate renderer in renderers) { | ||
| var tempActionFlags = *_ioActionFlags; | ||
| var tempTimeStamp = *_inTimeStamp; | ||
| renderer (tempActionFlags, tempTimeStamp, _inBusNumber, _inNumberFrames, buffers); |
There was a problem hiding this comment.
The temporary values here are unnecessary, because due to an incorrect binding, the ioActionFlags and inTimeStamp values aren't updated by the renderer callback:
| renderer (tempActionFlags, tempTimeStamp, _inBusNumber, _inNumberFrames, buffers); | |
| renderer (*_ioActionFlags, *_inTimeStamp, _inBusNumber, _inNumberFrames, buffers); |
These arguments should be ref arguments in the RenderDelegate: https://github.com/xamarin/xamarin-macios/blob/4c36652927ceb4098472a913b0e579000294d4c2/src/AudioUnit/AudioUnit.cs#L132
But that would be a breaking change, so we can't do that (we'd have to add (and correct) API instead of changing the existing one).
In any case, that's completely out of scope for this PR. I'd just make the .NET code just as broken as the non-.NET code, and maybe we'll get around to fixing it properly one day.
There was a problem hiding this comment.
Huh. I looked at this through a peephole and just saw ref args and figured that I should honor the ref-ness.
| #if NET | ||
| AudioUnitRenderActionFlags tempActionFlags = *actionFlags; | ||
| var tempTimeStamp = *timeStamp; | ||
| var returnValue = callback (tempActionFlags, tempTimeStamp, busNumber, numberFrames, buffers); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build] Test results 🔥Test results❌ Tests failed on VSTS: simulator tests 0 tests crashed, 206 tests failed, 4126 tests passed. Failures❌ bcl testsDetails
Html Report (VSDrops) Download ❌ cecil testsDetails
Html Report (VSDrops) Download ❌ dotnettests testsDetails
Html Report (VSDrops) Download ❌ fsharp testsDetails
Html Report (VSDrops) Download ❌ framework testsDetails
Html Report (VSDrops) Download ❌ generator testsDetails
Html Report (VSDrops) Download ❌ interdependent_binding_projects testsDetails
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build] Test results 🔥Test results❌ Tests failed on VSTS: simulator tests 0 tests crashed, 37 tests failed, 4295 tests passed. Failures❌ bcl testsDetails
Html Report (VSDrops) Download ❌ cecil testsDetails
Html Report (VSDrops) Download ❌ dotnettests testsDetails
Html Report (VSDrops) Download ❌ fsharp testsDetails
Html Report (VSDrops) Download ❌ framework testsDetails
Html Report (VSDrops) Download ❌ generator testsDetails
Html Report (VSDrops) Download ❌ interdependent_binding_projects testsDetails
Html Report (VSDrops) Download ❌ install_source testsDetails
Html Report (VSDrops) Download ❌ introspection testsDetails
Html Report (VSDrops) Download ❌ linker testsDetails
[Html Report (VSDrops)](https://vsdrop.corp.microsoft.com/file/v1/xamarin-macios/device-tests/20220901.\n\nThe message from CI is too large for the GitHub comments. You can find the full results here. |
|
I merged main into this PR to see if that fixes a few of the test failures. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
🔥 Failed to compare API and create generator diff 🔥 Error: 'make' failed for the hash 7511281. Pipeline on Agent |
❌ [PR Build] Tests on macOS Mac Catalina (10.15) failed ❌Tests on macOS Mac Catalina (10.15) failed for unknown reasons. Pipeline on Agent |
📚 [PR Build] Artifacts 📚Artifacts were not provided. Pipeline on Agent XAMMINI-013.Monterey |
❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌Failed tests are:
Pipeline on Agent |
🔥 [CI Build] Test results 🔥Test results❌ Tests failed on VSTS: simulator tests 0 tests crashed, 1 tests failed, 222 tests passed. Failures❌ bcl testsDetails
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
OK - this works, but you're not going to like it.
Why? Well, it comes down to this struct here:
What you're seeing in the
NETsection is what I think the struct should be for the fieldProcwhich represents the correct signature for the callback function. However, if I use this, I get the following errors:Which is particularly interesting for 3 reasons:
1 - both types are in scope - the actual declaration of a function that meets the contract works with no issue.
2 - making the types fully qualified makes no difference
3 - I AUGraph.cs, which I did first, I initially made a local version of the callback which was declared as an inner type but otherwise declared identically and it worked (!!)
So yes, this is a greasy, greasy, hack.
Why does it work? The types we're smudging are really just 32 bit integers, so no harm no foul. Well, a little foul.