dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.24k stars 1.76k forks source link

Drag & Drop using GestureRecognizers fails on Mac Catalyst #23627

Open jasonmsmith opened 4 months ago

jasonmsmith commented 4 months ago

Description

I am attempting to drag an image from one view in my app and drop it in another view. I use DragGestureRecorgnizer on the source view and DropGestureRecognizer on the target view. Everything works perfectly on Windows and iPad, but fails on Mac Catalyst. When attempting on Mac Catalyst, the following two lines show up in the standard output when I try to drag and drop:

2024-07-16 06:31:15.674 MacCatalystDragDropTest[1058:13565] Cannot find representation conforming to type com.apple.uikit.private.drag-item
2024-07-16 06:31:16.294 MacCatalystDragDropTest[1058:13565] *** Assertion failure in -[NSFilePromiseReceiver receivePromisedFilesAtDestination:options:operationQueue:reader:], NSFilePromiseReceiver.m:349

The first line appears when the drag begins. The second line appears when I attempt to drop. I have tried many combinations of settings & event handlers, but the error persists. It doesn't seem to matter what type of view I attach the GestureRecognizers to; the error is the same. I have even attempted to bypass the gesture recognizers and manipulate the underlying native views directly. I receive the same error in all cases.

After generating the output above, the drag & drop operation fails. The events/commands configured for Drop and/or DropCompleted are never called. The draggable view cannot be dragged again until the application is restarted.

Steps to Reproduce

  1. Create a new MAUI app using the standard template
  2. Add two views to the MainPage.xaml file, configured with DragGestureRecognizer and DropGestureRecognizer, respectively. Like so:

    <Image Source="dotnet_bot.png">
        <Image.GestureRecognizers>
            <DragGestureRecognizer/>
        </Image.GestureRecognizers>
    </Image>
    
    <Image Source="dotnet_bot.png">
        <Image.GestureRecognizers>
            <DropGestureRecognizer/>
        </Image.GestureRecognizers>
    </Image>
  3. Build and run the app with an attached debugger.
  4. Attempt to drag the first image to the second one. Observe the failure and accompanying messages in the output.

Link to public reproduction project repository

https://github.com/jasonmsmith/mac-catalyst-drag-drop-sample

Version with bug

8.0.61 SR6.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

No response

Did you find any workaround?

Not yet.

Relevant log output

No response

github-actions[bot] commented 4 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

ninachen03 commented 4 months ago

This issue has been verified using Visual Studio 17.16.12 (build 410) (8.0.70 &8.0.61). Can not be reproduced

jasonmsmith commented 4 months ago

By "latest version" do you mean MAUI 8.0.70, or do you want me to try .Net 9? I currently have .Net SDK 8.0.303 installed, which is the latest version of .Net 8 that I can find. The maui workload that I have installed is version 8.0.61/8.0.100, as reported by dotnet workload list.

I just tested the reproduction project using 8.0.70 and received exactly the same behavior reported in my initial post. (To change versions, I simply added the 8.0.70 tag to the .csproj and confirmed that the 8.0.70 NuGet packages were restored for the project).

I am using a Mac Mini with an M2 processor running Sonoma 14.1.1. I do not have Visual Studio on this machine; I removed it after the announcement several months ago that it was being retired. The download link on https://visualstudio.microsoft.com/vs/mac/ is currently broken for me. In both browsers I tried on my Mac, it redirects to the Windows download.

ninachen03 commented 3 months ago

According to the latest information you provided, it is reproduced on Mac Mini with an M2 processor VS17.6.13(build 424) (8.0.70 & 8.0.3) SDK version is 8.0.303 Note: not repro on Mac Mini with an intel processor and SDK version is 8.0.302. image

tj-devel709 commented 3 months ago

Hi this appears to be working on my end as well on a new maui project on 8.0.61 using VSCode on my mac.

https://github.com/user-attachments/assets/b5d84817-34ae-47b3-af63-643b66686d6a

tj-devel709 commented 3 months ago

And I do not get any errors when testing your sample

tj-devel709 commented 3 months ago

In a brand new maui project, do you still see this behavior?

jasonmsmith commented 3 months ago

In a brand new maui project, do you still see this behavior?

Yes, I do. @tj-devel709, can you confirm that you are using Apple Silicon and not Intel? Per @ninachen03, the issue is not reproducible on Intel macs.

I have already completed the following troubleshooting steps:

jasonmsmith commented 3 months ago

Yes, I do. @tj-devel709, can you confirm that you are using Apple Silicon and not Intel? Per @ninachen03, the issue is not reproducible on Intel macs.

@tj-devel709 Can you confirm this, please? I have a non-trivial B2B app that is dependent on this feature for one of its core functions. This bug is a show-stopper for us.

jasonmsmith commented 3 months ago

@davidortinau, @Eilon, @samhouts Can you comment on why your team has fallen silent on this issue without providing any guidance? I am overdue for reporting to my client about the outlook for fixing this issue. Please at least provide guidance on whether and/or when you intend to allocate any further resources to this bug within the next month. We are using MAUI to build a real business app on a real schedule & can't afford to wait indefinitely.

jasonmsmith commented 3 months ago

Hmm. That which I greatly feared has come upon me: it seems this bug is being ignored.

jasonmsmith commented 3 months ago

After further testing, I discovered that 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. Since Remote Management support is not a requirement for our app in production, I am OK with closing this issue. However, the bug does exist in Remote Management scenarios and may need further attention to support that use case.