Hi,
We are sometimes getting the following crash on Android after the user has closed a RadPopup. It does not happen every time so it looks like it is a timing issue. We have gotten the latest Telerik release and it is still happening in that version.
Below is the stack trace.
Regards
Anthony
System.ObjectDisposedException Message=Cannot access a disposed object. Object name: 'Android.Widget.PopupWindow'.
0x29 in Java.Interop.JniPeerMembers.AssertSelf at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153,5
0x1 in Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:57,5
0x12 in Android.Widget.PopupWindow.Dismiss at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Widget.PopupWindow.cs:1635,5
0xD in Telerik.XamarinForms.Primitives.RadPopup.DismissPopupWindow
0x12 in Telerik.XamarinForms.Primitives.RadPopup.SetPopupIsOpen
0x3A in Telerik.XamarinForms.Primitives.RadPopup.UpdatePopup
0x36 in Telerik.XamarinForms.Primitives.PopupBase.Animation_ProgressChanged
0x12 in Telerik.XamarinForms.Common.RadDoubleAnimation.OnProgressChanged
0x2C in Telerik.XamarinForms.Common.RadDoubleAnimation.OnAnimationTick
0x3 in Telerik.XamarinForms.Common.RadAnimation.Telerik.XamarinForms.Common.Animations.IDoubleAnimationListener.OnAnimationTick
0x42 in Telerik.XamarinForms.Common.Animations.AnimationTask.NotifyTick
0x53 in Telerik.XamarinForms.Common.Animations.AnimationTask.Tick
0x1B in Telerik.XamarinForms.Common.Animations.AnimationManager.HandleAnimationsTick
0x0 in Telerik.XamarinForms.Common.Animations.AnimationManager.TickAnimations
0x0 in Telerik.XamarinForms.Common.Animations.AnimationManager.TickAnimationsFunc
0x6 in Xamarin.Forms.Forms.AndroidPlatformServices. at D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:893,6
0xE in Java.Lang.Thread.RunnableImplementor.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36,6
0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Java.Lang.IRunnable.cs:84,4
0x8 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22,5
Hi Anthony,
For example, the exception may occur when the popup is disposed of and you try to show it. Is this exception occurs during navigation?
I will need more details on the setup, in order to research the case further. If you can send me a sample project where the issue occurs, that will be of great help.
If you do not want to attach the project to the forum thread, you can open a support ticket and attach it there.
Hi,
Unfortunately we have no idea where / when this is occurring as it is random and cannot be easily reproduced.
Looking at the stack trace the crash is occurring in Telerik code when DismissPopupWindow is called, there is no user code in the trace.
Some defensive programming in there could prevent this crash, similar to this issue which was fixed on the Telerik end:
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Widget.PopupWindow'. in UI for Xamarin | Telerik Forums
DateTimePicker: [Android] Prevent Dispose Exceptions when IsVisible is False (telerik.com)
Regards
Anthony
Hi Anthony,
The issue logged here: https://feedback.telerik.com/xamarin/1539473-datetimepicker-android-prevent-dispose-exceptions-when-isvisible-is-false was reproduced from our side and a fix for it was provided.
The control used is a DateTimePicker which uses the Popup internally. In your case I assume you use only the popup control. Without reproducing the issue I cannot research the case further.
You can try the solutions my colleague Lance suggested here: https://www.telerik.com/forums/system-objectdisposedexception-cannot-access-a-disposed-object-object-name-android-widget-popupwindow#5388513
Hi,
I understand it's difficult to test if it's not easily reproduced, however given I have provided a stack trace showing exactly where the exception is happening in the Telerik code, can someone take a look at the code and put in some defensive coding?
e.g. if popupwindow is disposed don't access it.
I am happy to take a look at the source code and suggest a fix if that helps my users. According to App Center, they have had over 200 crashes due to this issue in the last 4 weeks.
Regards
Anthony
Hi,
I will need the exact setup in which the exception occurs. In which page the popup is used, and whether the popup visibility is changed, during navigation, etc.? Yes, we have the stack-trace still we are not sure in what scenarios the exception occurs and we do not have the complete popup setup in the project where the issue occurs. We cannot apply a blind fix for this exception, as this can trigger another changes (exception, etc.). I hope you understand my point of view.
Also have you tried the suggestions added here: https://www.telerik.com/forums/system-objectdisposedexception-cannot-access-a-disposed-object-object-name-android-widget-popupwindow#5388513 to workaround the exception?
In addition we do not provide the source code for the Telerik Xamarin product. So I cannot share the popup implementation.