Quickly switching between tabs with Sfcharts on them can throw unhandled exception


I am now using 18.4.0.41. (Not sure if this existed in older versions.  Just noticed it.)

I have several tabs that have SfCharts on.  

If I wait until a chart on a tab is fully finished rendering, everything is fine.  
If I click on a tab with a chart and before it is fully finished drawing the first time, click back over to another tab, it will often throw an unhandled exception:

Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Object reference not set to an instance of an object.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.Blazor.Charts.SfChart.RefreshAxis()
   at Syncfusion.Blazor.Charts.SfChart.InitPrivateVariable()
   at Syncfusion.Blazor.Charts.SfChart.RenderChart()
   at Syncfusion.Blazor.Charts.SfChart.OnAfterScriptRendered()
   at Syncfusion.Blazor.SfBaseComponent.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.SfDataBoundComponent.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.Charts.SfChart.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'NtjU0g-6wE9oQqa8K4GJDwukAzEBK0_GEXkrSZpMee0'.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.Blazor.Charts.SfChart.RefreshAxis()
   at Syncfusion.Blazor.Charts.SfChart.InitPrivateVariable()
   at Syncfusion.Blazor.Charts.SfChart.RenderChart()
   at Syncfusion.Blazor.Charts.SfChart.OnAfterScriptRendered()
   at Syncfusion.Blazor.SfBaseComponent.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.SfDataBoundComponent.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.Charts.SfChart.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

Any way to prevent that?

Thanks in advance,
Jason



6 Replies 1 reply marked as answer

JI Jason Irby February 11, 2021 12:18 AM UTC

Some additional info...

Here is a sample project to demonstrate the issue:


Here is what I have found so far.  After I have upgraded to the latest Syncfusion version, I started seeing an annoying "Waiting to reconnect to server: 1 of 8" message every time I navigated to a tab with a chart on it.

Searching on your forum I saw a suggestion to add:
services.AddServerSideBlazor().AddHubOptions(
                options => { options.MaximumReceiveMessageSize = 102400000; });

I did that and that removed the annoying message.
However in the demo app, with that I can reproduce the issue by quickly switching between tabs.
In my app, after the annoying message my chart still rendered if I waited.

In the demo here, if I don't have that, the chart doesn't render, but it both cases, if it renders, switching quickly between tabs generates an unhandled exception.

In startup.cs, look for comment "// CAUSE OF EXCEPTION?"  Maybe that is the cause, or maybe it just allows to to be seen.  Comment that out, but then the chart won't render.  Don't understand why.  

Without that, the stupid "Waiting to reconnect to server: 1 of 8" is really annoying and wasn't doing it before I upgraded everything.  I hope I don't have to choose between user experience kill messages or unhandled exceptions. ;o)

Any ideas?  Thanks in advance.

Jason








BA Brian Armieri February 11, 2021 01:50 PM UTC

I'm having the exact same issue. 
Quickly switching tabs (at the immediate first render, before the charts are fully visible) kills the chart render with an "object reference not set" exception.
I believe this happens with both SfChart and SfAccumulationChart.



KR Kristof replied to Brian Armieri February 11, 2021 01:55 PM UTC

I'm having the exact same issue. 
Quickly switching tabs (at the immediate first render, before the charts are fully visible) kills the chart render with an "object reference not set" exception.
I believe this happens with both SfChart and SfAccumulationChart.


Yes. For me this happens both SfChart and SfAccumulationChart too.


BA Brian Armieri February 11, 2021 03:02 PM UTC

I *think* I have a temporary work-around until Syncfusion provides real support, but I'm not 100% sure... I haven't tested it enough to understand memory and other threading implications.  

The basic concept is to subclass the SfChart and SfAccumulationChart classes and trap the error.  Use these replacement TestChart and TestAccumulationChart components for SfChart and SfAccumulationChart. So far, when I do this it seems like the error is at least trapped:


    public class TestChart: SfChart    {
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            try
            {
                await base.OnAfterRenderAsync(firstRender);
            }
            catch (Exception ex)
            {
            }
        }
    }

    public class TestAccumulationChart: SfAccumulationChart
    {
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            try
            {
                await base.OnAfterRenderAsync(firstRender);
            }
            catch (Exception ex)
            {
            }
        }
    }



DG Durga Gopalakrishnan Syncfusion Team February 11, 2021 03:13 PM UTC

Hi Jason,

Greetings from Syncfusion.

We have already logged a defect report for this issue. This fix will be available in our upcoming weekly patch release which is scheduled to be rolled out on 16th February 2021. We appreciate your patience until then. You can keep track of the bug from the feedback portal below. 
  
  
The provided feedback link is private, and you need to login to view this feedback. 
  
If you have any more specification/precise replication procedure or a scenario to be tested, you can add it as a comment in the portal. 
  
Regards, 
Durga G 




DG Durga Gopalakrishnan Syncfusion Team February 16, 2021 03:41 PM UTC

Hi Jason,

We are glad to announce that our v18.4.43 patch release is rolled out; we have added the fix for reported issue. You can use the latest Syncfusion.Blazor NuGet package version.


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

Regards,
Durga G


Marked as answer
Loader.
Up arrow icon