unoplatform/uno

[Droid] `DoubleAnimation` in `ControlTemplate` `VisualState` throws Exception on call to `Convert.ToSingle()`

Open

#2.955 geöffnet am 7. Apr. 2020

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (837 Forks)batch import
difficulty/medium 🤔good first issuehas-repro-branchkind/bugproject/animations 🎡

Repository-Metriken

Stars
 (9.789 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 14T 8h) (130 gemergte PRs in 30 T)

Beschreibung

Current behavior

I created a new Button Template with some VisualState animations, including the following line: <DoubleAnimation Duration="00:00:00" Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" To="0.8"/> When the Button loads in the Droid head (works fine in UWP and I'm not messing with iOS), I get the following Exception:

Specified cast is invalid.
  at System.Convert.ToSingle (System.Object value) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/external/corefx/src/Common/src/CoreLib/System/Convert.cs:1595 
  at Windows.UI.Xaml.Media.Animation.DoubleAnimation.GetDefaultTargetValue () [0x0001e] in D:\a\1\s\src\Uno.UI\UI\Xaml\Media\Animation\DoubleAnimation.cs:425 
  at Windows.UI.Xaml.Media.Animation.DoubleAnimation.ComputeFromValue () [0x0005f] in D:\a\1\s\src\Uno.UI\UI\Xaml\Media\Animation\DoubleAnimation.cs:410 
  at Windows.UI.Xaml.Media.Animation.DoubleAnimation.InitializeAnimator () [0x00000] in D:\a\1\s\src\Uno.UI\UI\Xaml\Media\Animation\DoubleAnimation.cs:224 
  at Windows.UI.Xaml.Media.Animation.DoubleAnimation.Play () [0x00000] in D:\a\1\s\src\Uno.UI\UI\Xaml\Media\Animation\DoubleAnimation.cs:281 
  at Windows.UI.Xaml.Media.Animation.DoubleAnimation.Windows.UI.Xaml.Media.Animation.ITimeline.Begin () [0x00043] in D:\a\1\s\src\Uno.UI\UI\Xaml\Media\Animation\DoubleAnimation.cs:101 
  at Windows.UI.Xaml.Media.Animation.Storyboard.Play () [0x0004b] in D:\a\1\s\src\Uno.UI\UI\Xaml\Media\Animation\Storyboard.cs:111 
  at Windows.UI.Xaml.Media.Animation.Storyboard.Begin () [0x0007d] in D:\a\1\s\src\Uno.UI\UI\Xaml\Media\Animation\Storyboard.cs:100 
  at Windows.UI.Xaml.VisualStateGroup+<>c__DisplayClass29_0.<GoToState>b__1 (System.Object s, System.Object a) [0x000a8] in D:\a\1\s\src\Uno.UI\UI\Xaml\VisualStateGroup.cs:216 
  at Windows.UI.Xaml.VisualStateGroup.GoToState (Windows.UI.Xaml.IFrameworkElement element, Windows.UI.Xaml.VisualState state, Windows.UI.Xaml.VisualState originalState, System.Boolean useTransitions, System.Action onStateChanged) [0x0028d] in D:\a\1\s\src\Uno.UI\UI\Xaml\VisualStateGroup.cs:269 
  at Windows.UI.Xaml.VisualStateManager.GoToStateCore (Windows.UI.Xaml.Controls.Control control, Windows.UI.Xaml.IFrameworkElement templateRoot, System.String stateName, Windows.UI.Xaml.VisualStateGroup group, Windows.UI.Xaml.VisualState state, System.Boolean useTransitions) [0x000cc] in D:\a\1\s\src\Uno.UI\UI\Xaml\VisualStateManager.cs:216 
  at Windows.UI.Xaml.VisualStateManager.GoToState (Windows.UI.Xaml.Controls.Control control, System.String stateName, System.Boolean useTransitions) [0x0015a] in D:\a\1\s\src\Uno.UI\UI\Xaml\VisualStateManager.cs:165 
  at Windows.UI.Xaml.Controls.Button.UpdateCommonStates (System.Boolean useTransitions) [0x00007] in D:\a\1\s\src\Uno.UI\Mixins\Android\VisualStatesMixins.g.cs:366 
  at Windows.UI.Xaml.Controls.Button+<>c.<.cctor>b__0_2 (Windows.UI.Xaml.DependencyObject snd, Windows.UI.Xaml.DependencyPropertyChangedEventArgs e) [0x0000a] in D:\a\1\s\src\Uno.UI\Mixins\Android\VisualStatesMixins.g.cs:334 
  at (wrapper delegate-invoke) <Module>.invoke_void_DependencyObject_DependencyPropertyChangedEventArgs(Windows.UI.Xaml.DependencyObject,Windows.UI.Xaml.DependencyPropertyChangedEventArgs)
  at Windows.UI.Xaml.PropertyMetadata.RaisePropertyChanged (Windows.UI.Xaml.DependencyObject source, Windows.UI.Xaml.DependencyPropertyChangedEventArgs e) [0x00000] in D:\a\1\s\src\Uno.UI\UI\Xaml\PropertyMetadata.cs:144 
  at Windows.UI.Xaml.DependencyObjectStore.InvokeCallbacks (Windows.UI.Xaml.DependencyObject actualInstanceAlias, Windows.UI.Xaml.DependencyProperty property, Windows.UI.Xaml.DependencyPropertyDetails propertyDetails, System.Object previousValue, Windows.UI.Xaml.DependencyPropertyValuePrecedences previousPrecedence, System.Object newValue, Windows.UI.Xaml.DependencyPropertyValuePrecedences newPrecedence, System.Boolean bypassesPropagation) [0x000da] in D:\a\1\s\src\Uno.UI\UI\Xaml\DependencyObjectStore.cs:1430 
  at Windows.UI.Xaml.DependencyObjectStore.RaiseCallbacks (Windows.UI.Xaml.DependencyObject actualInstanceAlias, Windows.UI.Xaml.DependencyPropertyDetails propertyDetails, System.Object previousValue, Windows.UI.Xaml.DependencyPropertyValuePrecedences previousPrecedence, System.Object newValue, Windows.UI.Xaml.DependencyPropertyValuePrecedences newPrecedence) [0x0005b] in D:\a\1\s\src\Uno.UI\UI\Xaml\DependencyObjectStore.cs:1344 
  at Windows.UI.Xaml.DependencyObjectStore.InnerSetValue (Windows.UI.Xaml.DependencyProperty property, System.Object value, Windows.UI.Xaml.DependencyPropertyValuePrecedences precedence, Windows.UI.Xaml.DependencyPropertyDetails propertyDetails) [0x00193] in D:\a\1\s\src\Uno.UI\UI\Xaml\DependencyObjectStore.cs:475 
  at Windows.UI.Xaml.DependencyObjectStore.SetValue (Windows.UI.Xaml.DependencyProperty property, System.Object value, Windows.UI.Xaml.DependencyPropertyValuePrecedences precedence, Windows.UI.Xaml.DependencyPropertyDetails propertyDetails) [0x0002e] in D:\a\1\s\src\Uno.UI\UI\Xaml\DependencyObjectStore.cs:418 
  at Windows.UI.Xaml.DependencyObjectStore.SetValue (Windows.UI.Xaml.DependencyProperty property, System.Object value) [0x00000] in D:\a\1\s\src\Uno.UI\UI\Xaml\DependencyObjectStore.cs:382 
  at Uno.UI.Controls.BindableView.SetValue (Windows.UI.Xaml.DependencyProperty dp, System.Object value) [0x00000] in D:\a\1\s\src\Uno.UI\obj\Release\MonoAndroid90\g\DependencyObjectGenerator\Uno_UI_Controls_BindableView_72bb8e78163ad5c11de91e301960e619.g.cs:44 
  at Windows.UI.Xaml.FrameworkElement.set_IsEnabled (System.Boolean value) [0x00000] in D:\a\1\s\src\Uno.UI\Mixins\Android\FrameworkElementMixins.g.cs:1161 
  at XZ.Audio.UI.Player.Uno.MainPage.InitializeComponent () [0x00026] in C:\XZ\Audio\Branches\Uno\UI\Player\Uno\Droid\obj\Debug\90\g\XamlCodeGenerator\MainPage_0d3d6757d0b9ecfabe773d5f77a199d3.g.cs:52 
  at XZ.Audio.UI.Player.Uno.MainPage..ctor () [0x000b1] in C:\XZ\Audio\Branches\Uno\UI\Player\Uno\Shared\MainPage.xaml.cs:34 
  at XZ.Audio.UI.Player.Uno.MetadataBuilder_736.CreateInstance () [0x00000] in C:\XZ\Audio\Branches\Uno\UI\Player\Uno\Droid\obj\Debug\90\g\BindableTypeProvidersSourceGenerator\BindableMetadata.g.cs:35158 
  at Windows.UI.Xaml.Controls.Frame.CreatePageInstance (System.Type sourcePageType) [0x00016] in D:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:387 
  at Windows.UI.Xaml.PagePool.DequeuePage (System.Type pageType) [0x00007] in D:\a\1\s\src\Uno.UI\UI\Xaml\PagePool.cs:69 
  at Windows.UI.Xaml.Controls.Frame.CreatePageInstanceCached (System.Type sourcePageType) [0x00000] in D:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:377 
  at Windows.UI.Xaml.Controls.Frame.InnerNavigate (Windows.UI.Xaml.Navigation.PageStackEntry entry, Windows.UI.Xaml.Navigation.NavigationMode mode) [0x000ad] in D:\a\1\s\src\Uno.UI\UI\Xaml\Controls\Frame\Frame.cs:286 

If I comment out that one line, it runs fine (other than the fact that the animation doesn't run, of course). If I replace the DoubleAnimation with a DoubleAnimationUsingKeyFrames, everything works. If I replace Duration="00:00:00" with Duration="00:00:00.1", it works.

Expected behavior

It should run without the Exception.

How to reproduce it (as minimally and precisely as possible)

This doesn't happen with Opacity, but happens consistently when using DoubleAnimation with a Duration="00:00:00" on CompositeTransform.ScaleX (or Y).

Environment

Nuget Package:

Package Version(s): Uno.Core v2.0.0-dev.7 Uno.UI v2.2.0-dev.380

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio:

  • 2017 (version: )
  • 2019 (version: Community v16.5.2 )
  • for Mac (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

Contributor Guide