Android - Tapping On Chart To Show Tooltip Causes App Crashing

Hi guys,

We have a problem here with SFChart.

Here is our app setup: we have 3 fragments, and on each of them, we have a chart using column series. 
The chart data will be reloaded when the fragment comes to foreground.
We enabled the tooltip and animation on the chart.

Here is how we reproduce the bug:
- navigate to the the first fragment
- tap on the chart to get the tooltip shown after the animation is finished
- navigate to another fragment
- tap on the chart to get the tooltip shown after the animation is finished
- navigate to the previous fragment
- tap on the chart to get the tooltip (with or without waiting the animation is finished)
- app will crash

The exception we got is:
System.ObjectDisposedException: Cannot access a disposed object. 
Object name: 'Android.Graphics.PointF'.

Please let us know if this is a known bug, or if there is any walk around/ fix.

Thanks,
Ric

5 Replies

MK Muneesh Kumar G Syncfusion Team May 12, 2018 11:25 AM UTC

Hi Ric,

 

We have already fixed all issues based on disposed object in our latest version. Could you please update the SfChart version to latest (16.1.0.37) and check whether the issue reproduced in your application?

 

You can find the different options to get the latest version of SfChart component from here.

https://help.syncfusion.com/xamarin/introduction/download-and-installation  

 

The latest version of SfChart component is available in official nuget server as well.

https://www.nuget.org/packages/Syncfusion.Xamarin.SfChart/  

 

Please let us know if you are still facing any issue in this.

 

Regards,

Muneesh Kumar G.

 



RI Ric May 16, 2018 02:30 AM UTC

Hi Muneesh,

Thanks for the reply! 

We updated the SDK to the latest version. The bug is still there but the reproduce rate is lower. The new version seems to fix some part of the issue.

Here is our app setup: we have 3 fragments, and on each of them, we have a chart using column series. The chart data will be reloaded when the fragment comes to foreground. We enabled the tooltip and animation on the chart. And the column series is set to use gradient color. 

Here is how we reproduce the bug: 
- navigate to the the first fragment 
- tap on the chart to get the tooltip shown after the animation is finished 
- navigate to another fragment 
- tap on the chart to get the tooltip shown after the animation is finished 
- navigate to the previous fragment 
- tap on the chart to get the tooltip (with or without waiting the animation is finished) 
- after repeat the process for couple of times, the app will crash

Here is the exception we tracked:
  •  Main thread
    • 0
      android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
    • 1
      Object name: 'Android.Graphics.PointF'.
    • 2
      Java.Interop
      JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
    • 3
      Java.Interop
      JniPeerMembers+JniInstanceFields.GetSingleValue (System.String encodedMember, Java.Interop.IJavaPeerable self)
    • 4
      Android.Graphics
      PointF.get_X ()
    • 5
      Com.Syncfusion.Charts
      ChartSeries.GetGradientStartPoint (Com.Syncfusion.Charts.ChartSegment segment)
    • 6
      Com.Syncfusion.Charts
      ChartSegment.ApplyGradientColors (Android.Graphics.Paint paint)
    • 7
      Com.Syncfusion.Charts
      DrawingContext.DrawRect (System.Single left, System.Single top, System.Single right, System.Single bottom, Com.Syncfusion.Charts.ChartSegmentPaint chartSegmentPaint)
    • 8
      Com.Syncfusion.Charts
      ColumnSegment.OnDraw (Com.Syncfusion.Charts.Drawing drawing)
    • 9
      Com.Syncfusion.Charts
      ChartSegment.OnDraw (Android.Graphics.Canvas canvas)
    • 10
      Com.Syncfusion.Charts
      ChartSeries.Draw (Android.Graphics.Canvas canvas)
    • 11
      Com.Syncfusion.Charts
      SeriesRenderer.DrawSeries (Android.Graphics.Canvas canvas)
    • 12
      Com.Syncfusion.Charts
      SeriesRenderer.OnDraw (Android.Graphics.Canvas canvas)
    • 13
      Android.Views
      View.n_OnDraw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas)

Please let us know if this bug is still being fixed or there is any walk around for it.

Thanks,
Ric


MK Muneesh Kumar G Syncfusion Team May 16, 2018 10:21 AM UTC

Hi Ric, 
 
We are able to reproduce the issue “ObjectDisposedException thrown while navigating SfChart in fragment with GradientColors”, the fix for this issue will be available in our upcoming volume 2 release, which will be available on End of May 2018. However, we can resolve this issue by extending ColumnSeries and overriding GetGradientStartPoint and GetGradientEndPoint method as shown in below. 
 
Code snippet [C#]: 
public class CustomColumnSeries : ColumnSeries 
    { 
        protected override PointF GetGradientStartPoint(ChartSegment segment) 
        { 
            if (segment == null) return new PointF(0, 0); 
                                     
            var segmentBounds = (System.Drawing.RectangleF)segment.GetType(). 
                GetProperty("GradientBounds", System.Reflection.BindingFlags.NonPublic | 
                System.Reflection.BindingFlags.Instance).GetValue(segment); 
 
            var gradientStartPoint = ColorModel.CustomGradientColors[Segments.IndexOf(segment) % ColorModel.CustomGradientColors.Count].StartPoint; 
                
            Single startX = Single.IsNaN(gradientStartPoint.X) ? 0.5f : gradientStartPoint.X; 
            Single startY = Single.IsNaN(gradientStartPoint.Y) ?  1 : gradientStartPoint.Y; 
 
            return new PointF(segmentBounds.Left + segmentBounds.Width * startX, segmentBounds.Top + segmentBounds.Height * startY); 
        } 
 
        protected override PointF GetGradientEndPoint(ChartSegment segment) 
        { 
            if (segment == null) return new PointF(0, 0); 
 
            var segmentBounds = (System.Drawing.RectangleF)segment.GetType(). 
                GetProperty("GradientBounds", System.Reflection.BindingFlags.NonPublic | 
                System.Reflection.BindingFlags.Instance).GetValue(segment); 
 
            var gradientEndPoint = ColorModel.CustomGradientColors[Segments.IndexOf(segment) % ColorModel.CustomGradientColors.Count].EndPoint; 
 
            Single endX = Single.IsNaN(gradientEndPoint.X) ?  0.5f : gradientEndPoint.X; 
            Single endY = Single.IsNaN(gradientEndPoint.Y) ?  0 : gradientEndPoint.Y; 
 
            return new PointF(segmentBounds.Left + segmentBounds.Width * endX, segmentBounds.Top + segmentBounds.Height * endY); 
 
        } 
    } 
 
 
We have modified our sample based on that, please find the sample from the following location.   
 
 
Please let us know if you have any queries.  
 
Thanks,
Muneesh Kumar G.
 
 



RI Ric June 7, 2018 06:03 AM UTC

Hi Muneesh,

Thanks for the reply! 

We decided to use the updated SDK instead. It seems no latest version is available yet. Is there a ETA for the release?

And we found another similar issue:

Which is the StackedAreaSeries with gradient color will crash app when the fragment is changed. 

Is this issue coming from the same root? 

Thank you!

Ric


MK Muneesh Kumar G Syncfusion Team June 8, 2018 12:51 PM UTC

Hi Ric,  
 
Sorry for the inconvenience caused.  
 
Yes. This issue coming from the same root. This issue also fixed in our upcoming volume 2 release, which will be available by the end of Jun 2018. 
 
Please let us know if you have any queries.   
  
Thanks,
Muneesh Kumar G. 
 
 
 


Loader.
Up arrow icon