xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.59k stars 475 forks source link

[Bug] ShadowEffect causing exception #1344

Open Cfun1 opened 3 years ago

Cfun1 commented 3 years ago

Description

It seems ShadowEffect is causing an exception, could be a regression.

Steps to Reproduce

  1. Run the sample. make sure the xct dependency is 1.2.0-pre2.
  2. Long press on cards to enter edit mode.
  3. click cancel or save.

Expected Behavior

No exception.

Actual Behavior

Exception being thrown.

System.Reflection.TargetInvocationException
  Message=Exception has been thrown by the target of an invocation.
InnerException  {System.InvalidOperationException}  System.InvalidOperationException
StackTrace ``` at Xamarin.Forms.Color.MultiplyAlpha (System.Double alpha) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\Color.cs:151 at Xamarin.CommunityToolkit.Android.Effects.PlatformShadowEffect.Update () [0x0005c] in <078b17b9729e4d8fb573cff6b1ee501e>:0 at Xamarin.CommunityToolkit.Android.Effects.PlatformShadowEffect.OnElementPropertyChanged (System.ComponentModel.PropertyChangedEventArgs args) [0x000f9] in <078b17b9729e4d8fb573cff6b1ee501e>:0 at Xamarin.Forms.PlatformEffect`2[TContainer,TControl].SendOnElementPropertyChanged (System.ComponentModel.PropertyChangedEventArgs args) [0x00008] in D:\a\1\s\Xamarin.Forms.Core\PlatformEffect.cs:31 at Xamarin.Forms.RoutingEffect.SendOnElementPropertyChanged (System.ComponentModel.PropertyChangedEventArgs args) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\RoutingEffect.cs:39 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x0007a] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:375 at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property, System.Boolean fromStyle, System.Boolean checkAccess) [0x000f8] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:90 at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property, System.Boolean fromStyle) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:40 at Xamarin.Forms.Setter.UnApply (Xamarin.Forms.BindableObject target, System.Boolean fromStyle) [0x000be] in D:\a\1\s\Xamarin.Forms.Core\Setter.cs:117 at Xamarin.Forms.TriggerBase.OnConditionChanged (Xamarin.Forms.BindableObject bindable, System.Boolean oldValue, System.Boolean newValue) [0x00074] in D:\a\1\s\Xamarin.Forms.Core\Interactivity\TriggerBase.cs:106 at Xamarin.Forms.BindingCondition.OnBoundPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001d] in D:\a\1\s\Xamarin.Forms.Core\Interactivity\BindingCondition.cs:95 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:512 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160 at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56 at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762 at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773 at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666 at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160 at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56 at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762 at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773 at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 ```

Basic Information

Reproduction imagery

https://github.com/Cfun1/XamsungHealth/tree/e04b67ba4e8d2ada1302b15d60d931dc6010e68f

Reproduction Link

AndreiMisiukevich commented 3 years ago

Hi @Cfun1 InvalidOperationException hm, weird. It doesn't look like a crash of ShadowEffect. Can you please build a small (one-page) reproduction sample? (with xaml UI if possible).

There is a lot of code in the provided sample, I just want to exclude the possibility that there is a bug in your code.

Cfun1 commented 3 years ago

@AndreiMisiukevich Sure i will provide a smaller repo later, the thing is there was no exception with 1.1.0, after I have updated the package (with no parallel modifications) it started to happen on both 1.2.0-pre1 and 1.2.0-pre2.

AndreiMisiukevich commented 3 years ago

@AndreiMisiukevich Sure i will provide a smaller repo later, the thing is there was no exception with 1.1.0, after I have updated the package (with no parallel modifications) it started to happen on both 1.2.0-pre1 and 1.2.0-pre2.

Thank you) Perhaps we will have to force to update smth in UI thread. But would be great to have a small sample

jfversluis commented 3 years ago

@Cfun1 if you could provide us with that sample that would be great!