You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, we are using RiveAnimation in a widget where it is wrapped within a Visibility widget. This widget has maintainState=true.
In our usecase, when the widget becomes visible again - the animation is sometimes reset using SimpleAnimation.reset().
The problem is, that when maintainState is true, RiveRenderBox._stopwatch keeps going, and starts calling advance() when the widget becomes visible again. If the widget was invisible for 3 seconds, then advance() will be called with 3 seconds.
So, since we called reset(), we expect the time be at 0, but suddenly we are at 3 seconds, because of the advance() that was called.
This either forces us to use a Visibility widget with maintainState=false, or wait for the next frame and reduce the few seconds that were added (forcing us to count them...) - neither are good solutions.
The RiveRenderBox stopwatch keeps going because render box detach() is not called when maintainState is true, and paint is not called either because visibility is false, leading to a huge advance() call when the widget becomes visible again.
There should be either a way to reset this timer, or stop it while maintaining state.
Thanks!
Steps To Reproduce
Wrap RiveAnimation widget with Visibility widget that has maintainState=true. Use a SimpleAnimation controller.
Set visiblity as false.
Wait a few seconds.
Set visibility as true and call reset() on the Rive controller. (Happens also with microtask, no difference).
Animation playback position will now be at the amount of seconds widget was invisible.
Expected behavior
Rive animation time being at 0 when reset() is called
I just found out that under a Visibility widget with maintainState=false, each time visibility becomes false and then true, it seems that a RuntimeArtboard is leaking, according to the profiler. When it happens many times, RAM usage gets too high and app crashes. This does not happen with maintainState=true. Does this warrant a seperate issue?
For the time being, I have bypassed this by extending SimpleAnimation and ignoring the big 'tick'
class BypassRiveSimpleAnimation extends SimpleAnimation {
BypassRiveSimpleAnimation (super.animationName);
@override
void apply(RuntimeArtboard artboard, double elapsedSeconds) {
// Ignore pauses longer than 0.5 seconds. This to fix
// apply being called with the time item was hidden.
// This means when stopping and playing will not work properly if under than 0.5 seconds delay
if (elapsedSeconds >= 0.5) {
return;
}
super.apply(artboard, elapsedSeconds);
}
}
This works fine, though if stopping and starting in under 0.5 seconds, same problem will occur.
Description
Hi, we are using
RiveAnimation
in a widget where it is wrapped within aVisibility
widget. This widget hasmaintainState=true
.In our usecase, when the widget becomes visible again - the animation is sometimes reset using
SimpleAnimation.reset()
.The problem is, that when
maintainState
is true,RiveRenderBox._stopwatch
keeps going, and starts callingadvance()
when the widget becomes visible again. If the widget was invisible for 3 seconds, thenadvance()
will be called with 3 seconds.So, since we called
reset()
, we expect the time be at 0, but suddenly we are at 3 seconds, because of theadvance()
that was called.This either forces us to use a
Visibility
widget withmaintainState=false
, or wait for the next frame and reduce the few seconds that were added (forcing us to count them...) - neither are good solutions.The
RiveRenderBox
stopwatch keeps going because render boxdetach()
is not called whenmaintainState
is true, andpaint
is not called either because visibility is false, leading to a hugeadvance()
call when the widget becomes visible again.There should be either a way to reset this timer, or stop it while maintaining state.
Thanks!
Steps To Reproduce
RiveAnimation
widget withVisibility
widget that hasmaintainState=true
. Use aSimpleAnimation
controller.false
.true
and callreset()
on the Rive controller. (Happens also with microtask, no difference).Expected behavior
Rive animation time being at 0 when reset() is called
The text was updated successfully, but these errors were encountered: