Search code examples
c#.netdrag-and-dropmauimac-catalyst

.Net MAUI Drag & Drop fails on Mac Catalyst


TL;DR -- The Problem in a nutshell

Drag & Drop seems to be broken for .Net MAUI apps on Mac Catalyst, but only on Apple Silicon devices. I need a fix or workaround, but so far I've been unsuccessful.

Problem Details

I have built a non-trivial B2B app in .Net Maui 8 that relies heavily on "drag and drop" functionality to copy images from a list to a 2D layout. The client recently expanded project scope to include MacOS support (we previously supported iPad and Windows). Unfortunately, when running the app on Mac via Mac Catalyst, drag & drop is broken. When dragging begins, the following 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

Dragging appears to begin (the dragged item moves with the mouse pointer as expected). When I attempt to drop on the target, the following 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

The events/commands on the DropGestureRecognizer of the target do not fire, and the source element cannot be dragged again until the app is restarted.

Reproducing the Problem

I have created an extremely basic test app to confirm that the problem was not related to application-specific code in the main app. You can find the test app at this repo. It is a stock .Net Maui app with the following elements added 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>

This sample app displays identical behavior to my original app. Please note that this behavior has not yet been observed on Intel Macs. It has been confirmed on at least two devices using the Apple M2 processor.

My Mac Development Environment

  • Mac Mini with an Apple M2 processor
  • MacOS Sonoma 14.5 (also tested on 14.1.1)
  • Xcode 15.4
  • .Net SDK 8.0.303 (also observed in an earlier version)
  • .Net MAUI workload 8.0.61/8.0.100
  • .Net MAUI version 8.0.70 (also observed with 8.0.61 and another earlier version)

What I've Tried

  • Create a clean app to test (see above)
  • Completely uninstall .Net & Mono from my Mac and reinstall (same problems as before)
  • Attempt to bypass Gesture Recognizers and add UI interaction code directly to the native views following this and this example code. (The problem persists)
  • Report the problem to Microsoft. (They confirmed the behavior but then fell silent).

What 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 GestureRegonizers?


Solution

  • This bug is caused by operating the Mac via Remote Management (in my case, RealVNC Viewer). When connecting hardware and operating the Mac directly, the bug disappears. Remote Management support is not a requirement for our app in production, so I am marking this question as solved.