This bug was caused by operating the Mac via Remote Management. In my case, I used RealVNC Viewer from my Windows computer. (My desk is too small for two separate workstations, so I normally don't have a keyboard, mouse, or monitor connected directly to my Mac). When operating the app via directly-connected hardware, it functions as expected. Although it would be interesting to find the cause of the bug in remote management, I am marking this question as answered since the app is functional under normal operation. (Remote Management support is not a requirement in production)
.Net MAUI Drag & Drop crashes on Mac Catalyst with Apple Silicon
Overview
On Macs with Apple Silicon processors, Drag & Drop seems to be broken for .Net MAUI apps. I have tried multiple fixes/workarounds, but so far I haven't been successful. Do you have a better suggestion?
The Details
I have built a moderately complex B2B app in .Net Maui 8. One of it's core features uses "drag and drop" functionality to copy images from a list to a 2D layout. We recently adjusted our scope to include MacOS support. (Originally, we only targeted iPad and Windows). When running the app on Mac Catalyst, I get the following behavior:
When dragging begins, an error message is displayed in debug output:
2024-07-16 06:31:15.674 MacCatalystDragDropTest[1058:13565] Cannot find representation conforming to type com.apple.uikit.private.drag-item
However, the draggable view appears to begin the drag operation normally. A copy of the view follows the mouse pointer around the screen. When I drop the image on the target, this error appears in the debug output:
2024-07-16 06:31:16.294 MacCatalystDragDropTest[1058:13565] *** Assertion failure in -[NSFilePromiseReceiver receivePromisedFilesAtDestination:options:operationQueue:reader:], NSFilePromiseReceiver.m:349
None of the events or commands configured on the DropGestureRecognizer
of the target run. After the error, the source element cannot be dragged again until the app is re-launched.
A Minimal Reproducible Example
I have created a test app to demonstrate that the issue was not caused by any code in my main app. You can find the test app here. It is a standard .Net Maui app. The only change I made was adding the following elements to MainPage.xaml
:
<Image Source="dotnet_bot.png">
<Image.GestureRecognizers>
<DragGestureRecognizer/>
</Image.GestureRecognizers>
</Image>
<Image Source="dotnet_bot.png">
<Image.GestureRecognizers>
<DropGestureRecognizer/>
</Image.GestureRecognizers>
</Image>
When running this very simple app, I receive identical behavior to the original app. Important note: this issue has not yet been confirmed on Macs with Intel processors. To my knowledge, both devices where the behavior was observed had an Apple M2 processor.
Environment Details
- Computer: Mac Mini with an Apple M2 processor
- Operating system: MacOS Sonoma 14.5 (also tested on 14.1.1)
- Mac Dev Software: Xcode 15.4
- .Net version: .Net SDK 8.0.303 (also observed in an earlier version)
- Workloads: .Net MAUI workload 8.0.61/8.0.100
- Nugets: .Net MAUI version 8.0.70 (also observed with 8.0.61 and another earlier version)
Troubleshooting Steps Already Completed
- I have created a clean app to test (see above)
- I have completely uninstalled .Net & Mono from my Mac and reinstalled them (The behavior didn't change)
- I attempted to bypass
GestureRecognizer
s and add UI interaction code directly to the underlying native views following this and this example code. (I received the same error messages even with custom code) - I reported the problem to Microsoft. (They confirmed the behavior but haven't issued any guidance).
The next steps
I need a way forward! Can you help? Is there an alternate method to working with the native views? Something I'm missing with the GestureRegonizer
s?