Closed
Description
Animated grabs an interaction handle at the beginning of an animations and doesn't release it to the end. I see why it's doing this (so less important stuff doesn't interfere with the animation) but there are totally legitimate situations in which animations will be happening all the time without gaps so that the stuff waiting on InteractionManager will never get run).
A nasty example I've just encountered is a loading spinner that uses Animated to spin itself, while the loading spinner is showing my actually loading code will never run (since it tries to be friendly and wait for interactions to finish first).
A few solutions I can think off:
- Make sure that if an InteractionManager handle is created then released then another is created just after that any waiting actions get performed first. The problem here is that if the interactions are real user interactions then we probably want to wait.
- Don't grab an InteractionManager handle from Animated. This has the disadvantage that short animations which would have run smoother had that been done without any other negative effects will be impacted.
- Add an option to Animated to turn off InteractionManager stuff for just one animation. This does add extra API surface area (and in a way makes it easy to shoot yourself in the foot)
Any thoughts?
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
ide commentedon Aug 25, 2015
@vjeux and I separately encountered this too. I think we want these "fire and forget" animations to be marked as non-interactions as you suggest in idea #3.
One reason is that once the keyframes are computed in JS they can be passed to the main thread (future optimization). Even if the JS thread is tied up doing heavy work, the main thread can continue the animation which is perfect for things like spinners.
[-]Animated: Holds a InteractionManager handle for the entirety of each animation[/-][+][Animated] Holds a InteractionManager handle for the entirety of each animation[/+]aleclarson commentedon Sep 3, 2015
+1
idibidiart commentedon Nov 23, 2015
+1
ide commentedon Nov 23, 2015
I implemented option 3 here: #3433. It's pretty straighforward -- specify
isInteraction: false
in your animation config and Animated will not register an Interaction for the animation.