Xamarin.forms: [Bug] SwipeView crash with NullReferenceException

Created on 13 May 2020  路  3Comments  路  Source: xamarin/Xamarin.Forms

Description

When using swipeview to swipe navigate to another page, if I remove or pop a page from the stack, the app always crashes with the same error.

Steps to Reproduce

  1. Run the provided demo.
  2. Click the button on the homepage to go to Page 1.
  3. Swipe Left or Right to go to Page 2.
  4. The error is thrown here

Expected Behavior

Page 2 is displayed and page 1 was popped out of the navigation stack with no errors.

Actual Behavior

Throws error: "System.NullReferenceException: Object reference not set to an instance of an object"

AppCenter Trace

SwipeViewRenderer.UpdateIsOpen (System.Boolean isOpen)
SwipeViewRenderer.DisposeSwipeItems ()
SwipeViewRenderer.<ResetSwipe>b__71_0 ()
Runnable.Run ()
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.47(intptr,intptr)

Basic Information

Visual Studio 2019
Xamarin.Forms v4.6

Reproduction Link

SwipeViewDemo.zip

navigation swipeview 2 high in-progress Android bug

Most helpful comment

I experienced the same bug when deleting the item in the list while the SwipeView is open and are animating back to closed.

One work around until #10682 is merged is to set : SwipeBehaviorOnInvoked="RemainOpen" for the SwipeItems.

All 3 comments

I experienced the same bug when deleting the item in the list while the SwipeView is open and are animating back to closed.

One work around until #10682 is merged is to set : SwipeBehaviorOnInvoked="RemainOpen" for the SwipeItems.

The fix on this PR https://github.com/xamarin/Xamarin.Forms/pull/10827/commits/3a2826c6350d1a05c9cbc1e4c9d9537a40d208fd was already merged into main branch, however it was not merged into 4.7.0 branch yet.
Waiting for the xamarin team @samhouts @davidortinau @rmarinho @pauldipietro @jsuarezruiz to release it into the next stable release.

Just submitted the same fix for iOS https://github.com/xamarin/Xamarin.Forms/pull/11292

Was this page helpful?
0 / 5 - 0 ratings