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)