microsoft / WindowsCompositionSamples

The Windows Composition Samples have moved here: https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/SceneGraph
https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/SceneGraph
MIT License
1.12k stars 287 forks source link

AnimationController.Progress always return zero #346

Closed douglassch closed 4 years ago

douglassch commented 4 years ago

Issue Type

[ x] Bug Report

Current Behavior

The reading of AnimationController.Progress property always return zero while running a KeyFrameAnimation.

Expected Behavior

Return the current playback position of the animation.

Steps to Reproduce (for bugs)

I'm using this sample as base code for test: https://github.com/microsoft/WindowsCompositionSamples/tree/master/Demos/Reference%20Demos/Animations_KeyFrame/Animate_Visual_Position

I added a timer callback to read the progress:

private void timerCallback(object state) { double progress = _target.TryGetAnimationController("Offset")?.Progress ?? double.NaN; Debug.WriteLine(progress.ToString()); }

The timer is enabled in the "Animate_Click" event after init the animation.

Your Environment

mevey commented 4 years ago

@douglassch AnimationController.Progress property always return zero while running a KeyFrameAnimation is by design. This is the same for any other property in composition that’s driven by an animation. We don’t do per-frame readback of any animated properties.

Here are some suggested workarounds:

douglassch commented 4 years ago

Thanks @mevey, I believe CompositionScopeBatch solves my problem, but I was confused about the API documentation because it seems that the property should be accessible throughout the animation once access to the controller is obtained.

I imagine that the derived class Object-> CompositionObject-> CompositionAnimation-> KeyFrameAnimation-> Vector3KeyFrameAnimation does not implement updating of the Progress property, is this expected or is it really an API bug?