From 2544755918c5916fe4ae2c4928b15989421fb96b Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Sat, 17 Feb 2024 01:22:36 +0200 Subject: [PATCH] chore: Fix --- .../Composition/CompositionObject.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Uno.UI.Composition/Composition/CompositionObject.cs b/src/Uno.UI.Composition/Composition/CompositionObject.cs index 830f35a319db..728126c41681 100644 --- a/src/Uno.UI.Composition/Composition/CompositionObject.cs +++ b/src/Uno.UI.Composition/Composition/CompositionObject.cs @@ -6,6 +6,7 @@ using System.Numerics; using System.Runtime.CompilerServices; using Microsoft.UI.Dispatching; +using Uno.Foundation.Logging; using Windows.Foundation.Metadata; using Windows.UI; using Windows.UI.Core; @@ -70,7 +71,20 @@ public void StartAnimation(string propertyName, CompositionAnimation animation) _animations[propertyName] = animation; animation.PropertyChanged += ReEvaluateAnimation; var animationValue = animation.Start(); - this.SetAnimatableProperty(propertyName, animationValue); + + try + { + this.SetAnimatableProperty(propertyName, animationValue); + } + catch (Exception ex) + { + // Important to catch the exception. + // It can currently happen for non-implemented animations which will evaluate to null and the target animation property is value type. + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError($"An exception occurred while setting animation value '{animationValue}' to property '{propertyName}' for animation '{animation}'. {ex.Message}"); + } + } } private void ReEvaluateAnimation(CompositionAnimation animation)