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

Conversation

@samhouts
Copy link
Contributor

@samhouts samhouts commented Jun 24, 2017

Description of Change

Clicking a button quickly to Navigate pages can cause a crash because we weren't always checking to see if the control was disposed. Now we're checking all over the place.

Bugs Fixed

  • None

API Changes

None

Behavioral Changes

None

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

void UpdateBitmap()
{
if (Element == null)
if (Element == null || _isDisposed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we do the check at a single place, in OnPropertyChanged ? and do it on the base class, so it applies to all controls ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods are called all over this renderer, not just in OnPropertyChanged. The original PR that "fixed" this issue added it in just OnElementChanged. This seemed like the best way to prevent regressing this bug, and since it's a crasher, I wanted to be safe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@rmarinho rmarinho merged commit 39dee7a into master Jun 26, 2017
@rmarinho rmarinho deleted the fastrendererbuttoncrash branch June 26, 2017 18:11
void UpdateDrawable()
{
_backgroundTracker.UpdateDrawable();
_backgroundTracker?.UpdateDrawable();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why there is no disposed check here?

@VitalyKnyazev
Copy link
Contributor

Were latest checks included into 2.3.5.255-pre5?

Still crashing with "CANNOT ACCESS A DISPOSED OBJECT. OBJECT NAME: 'XAMARIN.FORMS.PLATFORM.ANDROID.FASTRENDERERS.BUTTONRENDERER'" from within IVisualElementRenderer.GetDesiredSize.

Full call stack:

  • JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
  • JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
  • View.Measure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec)
  • IVisualElementRenderer.GetDesiredSize (System.Int32 widthConstraint, System.Int32 heightConstraint)
  • IPlatform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint)
  • VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
  • VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)
  • VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint)
  • VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags)
  • Grid.CalculateAutoCells (System.Double width, System.Double height)
  • Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize)
  • Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height)
  • Layout.UpdateChildrenLayout ()
  • Layout.OnSizeAllocated (System.Double width, System.Double height)
  • Layout+<>c.b__39_0 ()
  • Thread+RunnableImplementor.Run ()

assemhakmeh added a commit to assemhakmeh/Xamarin.Forms that referenced this pull request Jul 28, 2017
* 2.3.5:
  [UWP] Fixes for usage of XF with .net native toolchain (xamarin#1024)
  [UWP] Make sure to update HitTestVisible when IsEnable changes (xamarin#1015)
  [Android] Dispose check before setting properties on Button (xamarin#1013)
  Add missing member variable to FormsApplicationActivity
  Fix NRE when background color of button set in FormsApplicationActivity (xamarin#1010)
  Fix border on android buttons  (xamarin#941)
  [iOS] ListView with UnevenRows and Cell Heights will no longer be slow to load (xamarin#994)
  Set the Id field for Android Views created by Forms xamarin#1004
  Fix build
  Fix possible crash on API 21+ at launch when using Holo theme and FormsApplicationActivity (xamarin#961)
  [Android] Remove the ". " on empty labels (Accessibility) on Fastrenderers (xamarin#915)
  Remove debug outputs (xamarin#1008)
  Add check for instance of UITableView (xamarin#885)
  [XamlC] fix release builds of Xaml Unit Tests
  Dispose check on ButtonRenderer (xamarin#975)
  [previewer] make sure we do not crash even if the previewer doesn't s… (xamarin#946)
  [XamlC] fix build
  Remove VisualElement finalizer (xamarin#918)
  [XamlC] process symbols if DebugType is set (xamarin#925)
@samhouts samhouts modified the milestones: 2.3.0, 2.3.5 Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants