Skip to content

UWP App with .NET Native Compilation enabled fails w/ FadeToAnimation #22

@mzhukovs

Description

@mzhukovs

Only with .NET Native Compilation enabled, a UWP app that uses a FadeToAnimation storyboard on appearing on a grid fails when setting Opacity=0 at Duration=0:

        <xamanimation:StoryBoard x:Key="EntriesAnimation" Target="{x:Reference UserEntries}">
            <xamanimation:FadeToAnimation Opacity="0" Duration="0" />
            <xamanimation:FadeToAnimation Opacity="1" Duration="500" />
        </xamanimation:StoryBoard>

The above results in a crash. Note that the same technique (applying at Duration 0) works just fine with TranslateTo, e.g. this works:

            <xamanimation:StoryBoard x:Key="LogoAnimation" Target="{x:Reference Logo}">
                <xamanimation:TranslateToAnimation TranslateY="500" Duration="0" />
                <xamanimation:TranslateToAnimation
                    Easing="SpringOut"
                    TranslateY="0"
                    Duration="750" />
            </xamanimation:StoryBoard>

The fix for me was to instead just do only <xamanimation:FadeToAnimation Opacity="1" Duration="500" /> and set the Opacity="0" explicitly on the Target Grid.

Here was the error in the former case:

System.Private.Interop.dll!System.Runtime.InteropServices.McgMarshal.ThrowOnExternalCallFailed(int hr, System.RuntimeTypeHandle typeHnd) Line 1189 at f:\dd\ndp\fxcore\CoreRT\src\System.Private.Interop\src\Shared\McgMarshal.cs(1189)

System.ArgumentException HResult=0x80070057 Message=Value does not fall within the expected range. Source= StackTrace: StackTrace " at System.Runtime.InteropServices.McgMarshal.ThrowOnExternalCallFailed(Int32 hr, RuntimeTypeHandle typeHnd) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Interop\src\Shared\McgMarshal.cs:line 1189\r\n at __Interop.ComCallHelpers.Call(__ComObject __this, RuntimeTypeHandle __typeHnd, Int32 __targetIndex, Double arg0)\r\n
at __Interop.ForwardComStubs.Stub_22[TThis](__ComObject __this, Double value, Int32 __targetIndex)\r\n at Windows.UI.Xaml.IUIElement__Impl.Stubs.put_Opacity(__ComObject __this, Double value)\r\n at Windows.UI.Xaml.UIElement.put_Opacity(Double value)\r\n at Xamarin.Forms.Platform.UWP.VisualElementTracker2.UpdateOpacity(VisualElement
view, FrameworkElement frameworkElement) in
D:\a\1\s\Xamarin.Forms.Platform.UAP\VisualElementTracker.cs:line
518\r\n at
Xamarin.Forms.Platform.UWP.VisualElementTracker2.UpdateNativeControl() in D:\a\1\s\Xamarin.Forms.Platform.UAP\VisualElementTracker.cs:line 236\r\n at Xamarin.Forms.Platform.UWP.VisualElementTracker2.OnRedrawNeeded(Object
sender, EventArgs e) in
D:\a\1\s\Xamarin.Forms.Platform.UAP\VisualElementTracker.cs:line
409\r\n at System.EventHandler1.Invoke(Object sender, TEventArgs e)\r\n at Xamarin.Forms.VisualElement.BatchCommit() in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:line 572\r\n at Xamarin.Forms.AnimationExtensions.HandleTweenerUpdated(Object o, EventArgs args) in D:\a\1\s\Xamarin.Forms.Core\AnimationExtensions.cs:line 274\r\n
at System.EventHandler.InvokeOpenStaticThunk(Object sender, EventArgs e)\r\n at System.EventHandler.Invoke(Object sender, EventArgs e)\r\n at Xamarin.Forms.Tweener.b__22_0(Int64 step) in D:\a\1\s\Xamarin.Forms.Core\Tweener.cs:line 92\r\n at System.Func2.Invoke(T arg)\r\n at
Xamarin.Forms.Internals.Ticker.SendSignals(Int64 step) in
D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:line 136\r\n

at Xamarin.Forms.Internals.Ticker.SendSignals(Int32 timestep) in
D:\a\1\s\Xamarin.Forms.Core\Internals\Ticker.cs:line 125\r\n

at
Xamarin.Forms.Platform.UWP.WindowsTicker.RenderingFrameEventHandler(Object
sender, Object args) in
D:\a\1\s\Xamarin.Forms.Platform.UAP\WindowsTicker.cs:line 25\r\n
at System.EventHandler1.Invoke(Object sender, TEventArgs e)\r\n at __Interop.Intrinsics.HasThisCall__51(Object __this, IntPtr pfn, Object arg0, Object arg1)\r\n at __Interop.ReverseComStubs.Stub_41(Object __this, Void* unsafe_sender, Void* unsafe_args, IntPtr __methodPtr)" string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions