telerik / UI-For-UWP

This repo contains the source code for Telerik UI for Universal Windows Platform (UWP), which includes 20+ UI controls for developers building UWP applications.
http://www.telerik.com/uwp/
Other
1.16k stars 234 forks source link

Do not throw when Series is null as it causes unnecessary app crash #517

Open VitalyKnyazev opened 1 year ago

VitalyKnyazev commented 1 year ago

Here is a stack trace from App Center, it is a rare crash but still happens, never reproduced in dev environment:

System.ArgumentNullException: Value cannot be null. Telerik.UI.Xaml.Controls.Chart ChartTrackBallBehavior.GetIntersectionTemplate ($DependencyObject instance) C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\Behaviors\Trackball\ChartTrackBallBehavior.cs at 245:17 Telerik.UI.Xaml.Controls.Chart ChartTrackBallBehavior.UpdateIntersectionPoints ($ChartDataContext context) C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\Behaviors\Trackball\ChartTrackBallBehavior.cs at 698:17 Telerik.UI.Xaml.Controls.Chart ChartTrackBallBehavior.UpdateVisuals () C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\Behaviors\Trackball\ChartTrackBallBehavior.cs at 578:17 Telerik.UI.Xaml.Controls.Chart ChartTrackBallBehavior.OnChartUIUpdated () C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\Behaviors\Trackball\ChartTrackBallBehavior.cs at 454:17 Telerik.UI.Xaml.Controls.Chart RadChartBase.NotifyUIUpdated () C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\RadChartBase.Manipulation.cs at 507:17 Telerik.UI.Xaml.Controls.Chart RadChartBase.OnUIUpdated () C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\RadChartBase.Manipulation.cs at 57:13 Telerik.UI.Xaml.Controls.Chart PresenterBase.UpdateUI ($ChartLayoutContext context) C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\Common\PresenterBase.cs at 185:13 Telerik.UI.Xaml.Controls.Chart RadChartBase.CallUpdateUI () C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\RadChartBase.cs at 990:13 Telerik.UI.Xaml.Controls.Chart RadChartBase.ArrangeOverride ($Size finalSize) C:_J\workspace\Nupkg_UWP_OpenSource\Controls\Chart\Chart.UWP\Visualization\RadChartBase.cs at 766:13 Windows.UI.Xaml.FrameworkElement.global.Windows.UI.Xaml IFrameworkElementOverrides.ArrangeOverride ($Size finalSize) global::Microsoft.UI.Xaml.Controls.IVirtualizingLayoutOverrides.MeasureOverride at 16707566 Interop ReverseComStubs.Stub_13 (Object this, $Size unsafe_availableSize, $Size* unsafe_resultretval, IntPtr __methodPtr) Stub_13 at 15732480 System.Runtime.InteropServices McgMarshal.ThrowOnExternalCallFailed (Int32, RuntimeTypeHandle) Interop ComCallHelpers.Call ($ComObject this, RuntimeTypeHandle typeHnd, Int32 targetIndex) Call at 15732480 Interop.ForwardComStubs Stub_20 (Void* InstParam, $ComObject this, Int32 __targetIndex) Stub_20 at 16707566 Microsoft.AppCenter.Utils ApplicationLifecycleHelper.b17_1 (Object sender, $UnhandledErrorDetectedEventArgs eventArgs)

VitalyKnyazev commented 1 year ago

@polqnaP @dilyantraykov @APopatanasov @vvgeorgiev Hello, could you please review this PR? This crash still happens in prod from time to time.

ivan-todorov-progress commented 1 year ago

@VitalyKnyazev Please, excuse us for the late response.

The fix seems safe to me, since the only place we are calling this method performs a null check for the returned DataTemplate. I am not certain if this is the right fix, however, or we are just trying to cure the symptom, instead of the actual problem. I believe, the real problem is why the series are null in the first place? This null check might avoid that particular crash, but it is unknown whether the app would not crash in another place later for the same reason.

I mean, this might be a symptom for a bigger problem, which might be a bug in the Chart itself or a bug in the application that is using it. Since we do not have the source code of the application, we cannot validate that on our side. Have you tried to open an issue in our support portal? There you can submit some source code to debug on our side, without fear it would go to the public.

ivan-todorov-progress commented 1 year ago

@VitalyKnyazev Kindly reminder: please fill in the Contributor's License Agreement, if you have not done so already, as described here: https://github.com/telerik/UI-For-UWP/blob/development/CONTRIBUTING.md.

VitalyKnyazev commented 1 year ago

@ivan-todorov-progress Hi Ivan, the issue only happens for a bunch of production users and I never could reproduce it locally, so not sure what sample I can upload.

That functionality is quite "disconnected" from the main chart and only relates to trackball, I believe it is safe to patch and then in a few months we will see if the issue is gone (most likely) or we have another NRE somewhere else.