Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
0
High-Frequency Blazor Chart throws NullReferenceException after couple of seconds
posted

I used the 1st example from this  link in my new Blazor Server project.

Below is a sample code I modified from Sample:

After starting the real-time plotting Chart throws NullReferenceException in Notify...() methods.

Below is the stack-trace:

Trace 1 -

   at System.Collections.Generic.LinkedList`1.InternalRemoveNode(LinkedListNode`1 node)
   at System.Collections.Generic.LinkedList`1.RemoveFirst()
   at IgniteUI.Blazor.Controls.BaseRendererControl.Update()
   at IgniteUI.Blazor.Controls.BaseRendererControl.<SendMessageImmediate>d__124.MoveNext()
   at IgniteUI.Blazor.Controls.BaseRendererControl.<InvokeMethodHelper>d__106.MoveNext()
   at IgniteUI.Blazor.Controls.BaseRendererControl.<InvokeMethod>d__100.MoveNext()
   at IgniteUI.Blazor.Controls.IgbDomainChart.<NotifyInsertItemAsync>d__1344.MoveNext()
   at InfragisticsBlazor.Pages.EegChart.<OnDataUpdate>d__13.MoveNext() in C:\GitRepo\GHE\architecture_team_prototypes\InfragisticsBlazor\InfragisticsBlazor\Pages\EegChart.razor:line 65

Trace 2 -

     at IgniteUI.Blazor.Controls.BaseRendererControl.IgniteUI.Blazor.Controls.RefSink.OnRefNotifyInsertItem(IJSDataSource dataSource, String refName, Int32 index, Object refItem)
   at IgniteUI.Blazor.Controls.DataSourceManager.NotifyInsertItem(String refName, Int32 index, Object refItem)
   at IgniteUI.Blazor.Controls.JsonDataSource.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at InfragisticsBlazor.Pages.EegChart.<OnDataUpdate>d__13.MoveNext() in C:\GitRepo\GHE\architecture_team_prototypes\InfragisticsBlazor\InfragisticsBlazor\Pages\EegChart.razor:line 64

Please help.

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello Dheeraj,

    To summarize the answer I gave you in a private support case, this exception was happening specifically due to this being Blazor Server, as the sample at the link you provided is a Blazor WASM (Web Assembly) sample. In Web Assembly, things can happen synchronously, but this is not the case in Blazor Server where, as I understand it, just about everything happens async.

    The issue here was actually that the Notify-related methods are even being called because the sample is using an ObservableCollection as the underlying data source, and the IgbCategoryChart responds to the INotifyCollectionChanged interface that is implemented on the underlying ObservableCollection type by default.

    Still, since it is Blazor Server, some things need to happen a little differently with async / await, and you cannot just directly remove and add a new item, or you may run into a race condition where you end up with another exception. I am attaching a sample that demonstrates the above.

    IgbChartHighFrequencyServer.zip

Children
No Data