Pre loader

Application hangs upon displaying chart for the first time

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


I have a WPF app where a UserControl is created at startup. The control contains two SciChartSurface objects, both initially invisible. About every 10th time I start the application it hangs on the thread with this call stack:

mscorlib.dll!System.Collections.Generic.ObjectEqualityComparer<System.__Canon>.Equals(System.__Canon x, System.__Canon y)    
mscorlib.dll!System.Collections.Generic.List<System.IComparable>.Contains(System.IComparable item)   
SciChart.Charting.dll!SciChart.Charting.Numerics.TickProviders.TimeSpanTickProviderBase.c5b456a75ec2eca07ab2f0cf38c30f4f2(SciChart.Data.Model.IRange cb7f8a302c4d43c2cfce28a7f59c09882, SciChart.Charting.Model.IAxisDelta<System.TimeSpan> cf1435e1ac3c185934e905ec126bcd3fa)   
SciChart.Charting.dll!SciChart.Charting.Numerics.TickProviders.TimeSpanTickProviderBase.GetMajorTicks(SciChart.Charting.Visuals.Axes.IAxisParams axis)   
SciChart.Charting.dll!SciChart.Charting.Numerics.TickProviders.TickProvider<System.IComparable>.caf851e93289795305ee933ce4bbca448(SciChart.Charting.Visuals.Axes.IAxisParams c050e7b647895decc0313c2786c4fc396)  
SciChart.Charting.dll!SciChart.Charting.Visuals.Axes.AxisBase.OnDraw(SciChart.Drawing.Common.IRenderContext2D renderContext, SciChart.Charting.Visuals.RenderableSeries.IRenderPassData renderPassData)  
SciChart.Charting.dll!A.c68de5aaca24f8f81d98aed29fac3caff.c6a7d2b5be124728330bbf562594a9bb9(SciChart.Charting.Visuals.ISciChartSurface c17037e8328cd0abc02d2a6957dfa450c, SciChart.Charting.Services.RenderPassInfo c16b8d70d2b6ecad8f9fca7ac3f5177b8, SciChart.Drawing.Common.IRenderContext2D c41db0419b661c8ac05a2aa6a1ea66092)   
SciChart.Charting.dll!A.c68de5aaca24f8f81d98aed29fac3caff.RenderLoop(SciChart.Drawing.Common.IRenderContext2D renderContext)     
SciChart.Charting.dll!SciChart.Charting.Visuals.SciChartSurface.OnRenderSurfaceDraw(object sender, SciChart.Drawing.Common.DrawEventArgs e)  
SciChart.Drawing.dll!SciChart.Drawing.Common.RenderSurfaceBase.OnRenderSurfaceBaseLoaded(object sender, System.Windows.RoutedEventArgs e)    
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs)  
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised)

The CPU spikes and the app never responds. Any thoughts as to why this might happen?

  • Yuriy Zadereckiy
    Hi Dan, thanks for reporting. It looks that ticks generation ends in an infinite loop. Could you please check the values of the MajorDelta, MinorDelta properties on the axis which hangs the app? I guess it is an X axis, DateTimeAxis or TimeSpanAxis.
  • Yuriy Zadereckiy
    Also, if possible, you can try to reproduce the issue in a simple project and send it to us for investigation.
  • Dan Pilat
    Yes, I have two chart surfaces that are kept in sync using a VerticalChartGroup. Both surfaces have a single x-axis of type DateTimeAxis. I use the properties: DrawMajorBands=”False” DrawMinorTicks=”False” DrawMinorGridLines=”False” Visibility=”Collapsed” VisibleRange=”{Binding VisibleTimeRange, Mode=OneWay}” AutoRange=”Never” AutoTicks=”False” MajorDelta=”00:00:01″ MinorDelta=”00:00:00.500″. The chart surface on top uses DrawLabels=”False”, where the bottom one is True. I’ll do what I can to get a bare bones reproduction of the issue.
  • Dan Pilat
    Initially the property VisibleTimeRange is null. Could this be responsible/partly responsible? I’m finding this harder and harder to reproduce, so I’m taking a stab in the dark here. Also note that the chart need not be visible for this error to occur. In fact, in our case it’s never made visible.
  • You must to post comments

Hi Dan, during the initialization phase of SciChart the axis is given a default valid visiblerange of 0,10.

For DateTimeAxis I believe this is todays date + 10 days.

The Axis behaves as follows

  1. On startup, set the axis VisibleRange to default range of 0,10
  2. Check if there is any data
  3. If YES data and Axis.AutoRange is Once or Always, perform an autorange to fit the data
  4. IF NO data, keep axis visiblerange to the default value of 0,10
  5. If at any time a user sets an invalid range, e.g. NULL or NaN or DoubleRange(11,10) where Min is greater than max, set the last known valid range

What I think is happening is you are setting your Axis.VisibleRange to null, either via a binding, or in code. Then, the axis starts up and tries to do the sequence above. It fails to find a range so it sets its range to 0,10. Now you have set MinorDelta to 0.5 seconds. As a result, SciChart generates 1.7million minor gridlines over 10 days, spaced 0.5 seconds apart – hence your hang!

What I suggest you do is to control this dynamically by only setting the MinorDelta, MajorDelta when it is safe to do so — when range is not absurdly large.

Or, if you want finer grained control over the axis Tick / Label output then please see our TickProvider API.

Best regards,

  • Dan Pilat
    Andrew that was it. Instead of null, I set the visible range to 4 seconds and I haven’t seen the problem for days. Thanks for your help.
  • Andrew Burnett-Thompson
    Great! Glad it is sorted.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.