Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] NullReferenceException in DragAndDropGestureHandler.<OnLongPress> on Android #14552

Closed
mfeingol opened this issue Aug 31, 2021 · 6 comments · Fixed by #14634
Closed

[Bug] NullReferenceException in DragAndDropGestureHandler.<OnLongPress> on Android #14552

mfeingol opened this issue Aug 31, 2021 · 6 comments · Fixed by #14634

Comments

@mfeingol
Copy link

Description

NullReferenceException inside Xamarin.Forms when using a DragGestureRecognizer. I believe this is a regression, possibly in the latest XF release, but I'm not 100% sure.

Steps to Reproduce

  1. Create a page containing a ListView, whose Viewcells have a StackLayout with a CheckBox and a Label. Add a DragGestureRecognizer to the Label.
  2. Open that page on a real phone.
  3. Start tapping the checkboxes with your finger.
  4. See if you can tap them all before the page crashes

Expected Behavior

No exceptions thrown.

Actual Behavior

NullReferenceException inside Xamarin.Forms. I haven't been able to reproduce this in a debugger, but it's easy with a release build on a phone. This is the stack trace:

DragAndDropGestureHandler.b__19_0 (Xamarin.Forms.DragGestureRecognizer rec)
DragAndDropGestureHandler.SendEventArgs[TRecognizer] (System.Action`1[T] func, Xamarin.Forms.View view)
DragAndDropGestureHandler.OnLongPress (Android.Views.MotionEvent e)
IOnGestureListener.OnLongPress (Android.Views.MotionEvent e)
GestureDetector+IOnGestureListenerInvoker.n_OnLongPress_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.164(intptr,intptr,intptr)

Basic Information

  • Version with issue: 5.0.0.2083
  • Last known good version: Unknown
  • Platform Target Frameworks:
    • Android: 11.0 (R)
  • Android Support Library / AndroidX Version: Latest
  • NuGet Packages:
  • Affected Devices:

Environment

Microsoft Visual Studio Enterprise 2019
Version 16.11.2
VisualStudio.16.Release/16.11.2+31624.102
Microsoft .NET Framework
Version 4.8.04084

Xamarin 16.11.000.174 (d16-11@e8f56f1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.11.0.17 (remotes/origin/11e0001f0b17269345e80b58fb3adf1ba4efe2cd@11e0001f0)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.10.5 (355b57a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 11.4.0.5 (d16-11/7776c9f)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: c633fe9
Java.Interop: xamarin/java.interop@48766c0
ProGuard: Guardsquare/proguard@912d149
SQLite: xamarin/sqlite@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools@683f375

@mfeingol mfeingol added s/unverified New report that has yet to be verified t/bug 🐛 labels Aug 31, 2021
@jsuarezruiz jsuarezruiz added this to New in Triage via automation Sep 3, 2021
@jsuarezruiz
Copy link
Contributor

Could you attach a small sample where reproduce the issue?. Thanks.

@jsuarezruiz jsuarezruiz moved this from New to Needs Info in Triage Sep 10, 2021
@jsuarezruiz jsuarezruiz added p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels Sep 10, 2021
@mfeingol
Copy link
Author

@jsuarezruiz: here's a repro project.

DragAndDropCrashRepro.zip

Can't reproduce in emulator, but was able to reproduce with a debug build on a physical device. Just drag and drop items around until you see a NullReferenceException here:

0x1 in System.Diagnostics.Debugger.Mono_UnhandledException at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Diagnostics/Debugger.cs:125,4	C#	Annotated Frame
0x26 in Android.Runtime.DynamicMethodNameCounter.87	C#	Annotated Frame
0x1D in Xamarin.Forms.Platform.Android.DragAndDropGestureHandler.<OnLongPress>b__19_0 at D:\a\1\s\Xamarin.Forms.Platform.Android\DragAndDropGestureHandler.cs:254,5	C#	Annotated Frame
0x3F in Xamarin.Forms.Platform.Android.DragAndDropGestureHandler.SendEventArgs<Xamarin.Forms.DragGestureRecognizer> at D:\a\1\s\Xamarin.Forms.Platform.Android\DragAndDropGestureHandler.cs:103,5	C#	Annotated Frame
0x17 in Xamarin.Forms.Platform.Android.DragAndDropGestureHandler.OnLongPress at D:\a\1\s\Xamarin.Forms.Platform.Android\DragAndDropGestureHandler.cs:247,4	C#	Annotated Frame
0xE in Xamarin.Forms.Platform.Android.InnerGestureListener.Android.Views.GestureDetector.IOnGestureListener.OnLongPress at D:\a\1\s\Xamarin.Forms.Platform.Android\InnerGestureListener.cs:120,4	C#	Annotated Frame
0x11 in Android.Views.GestureDetector.IOnGestureListenerInvoker.n_OnLongPress_Landroid_view_MotionEvent_ at /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.Views.GestureDetector.cs:612,5	C#	Annotated Frame
0x17 in Android.Runtime.DynamicMethodNameCounter.87	C#	Annotated Frame

@mfeingol
Copy link
Author

@jsuarezruiz: will that fix be released in an SR at some point?

Thanks.

@jfversluis
Copy link
Member

@mfeingol, a PR (#14634) for this is open now, would you be able to grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process.

Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂

Thanks!

@jfversluis jfversluis moved this from To Fix to PR Needs Review in 5.0.0 SR8 (Planning) - Target Date Dec. 15th Nov 18, 2021
@jfversluis jfversluis removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/unverified New report that has yet to be verified labels Nov 18, 2021
@mfeingol
Copy link
Author

Thanks, @jfversluis. I updated to 5.0.0.7867 from the PR feed and I was unable to repro the crash or any other issues with drag and drop in the context I discussed above. So I think we can call it a fix.

I guess it would be nice if the ListView scrolled when I drag something to the top or bottom of it. But that's a different conversation. :-)

@jfversluis
Copy link
Member

Perfect, thanks for letting us know!

Haha that is indeed a different conversation. On the other hand... Is that something the OS typically does? I'm now thinking of how iOS has implemented drag & drop OS wide. They also expect you to use 2 fingers and even drag & drop across different apps and such. Does dragging and scrolling up manually work?

Anyway, definitely something to think about here. Thanks for working together with us on this one!

Triage automation moved this from Needs Info to Closed Nov 24, 2021
5.0.0 SR8 (Planning) - Target Date Dec. 15th automation moved this from PR Needs Review to Done Nov 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
Closed
Development

Successfully merging a pull request may close this issue.

3 participants