Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the GestureDetector is disposed #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kvpt
Copy link
Contributor

@kvpt kvpt commented Mar 16, 2022

I received a log from a crash of my app that is related to the SwipeAwareContainerRenderer class used by the calendar.
From the stacktrace the crash seem to be caused by a press that try to access the renderer, but it has already been disposed so it crash the application.
This PR make two things :

  1. Ensure that the the gesture detector is disposed correctly like in Ensure that the GestureDetector is disposed #115
  2. Decouple the renderer from the gesture listener because the two have not the same lifecycle, by doing this we ensure that the gesture listener is disposed before the renderer which is not garanted when the renderer is itself the gesture listener

FYI, the stacktrace of the crash

System.NotSupportedException: Unable to activate instance of type Xamarin.Plugin.Calendar.Android.SwipeAwareContainerRenderer from native handle 0xffc46fdc (key_handle 0xe4b6c0a).
  at IJavaPeerable Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)
  at IJavaPeerable Java.Lang.Object.GetObject(IntPtr handle, JniHandleOwnership transfer, Type type)
  at IOnGestureListener Java.Lang.Object._GetObject<IOnGestureListener>(IntPtr handle, JniHandleOwnership transfer)
  at IOnGestureListener Java.Lang.Object.GetObject<IOnGestureListener>(IntPtr handle, JniHandleOwnership transfer) x 2
  at void Android.Views.GestureDetector+IOnGestureListenerInvoker.n_OnLongPress_Landroid_view_MotionEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_e)
--- End of inner exception stack trace ---
  System.MissingMethodException: No constructor found for Xamarin.Plugin.Calendar.Android.SwipeAwareContainerRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
    at object Java.Interop.TypeManager.CreateProxy(Type type, IntPtr handle, JniHandleOwnership transfer)
    at IJavaPeerable Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant