Skip to content

[Animated] Holds a InteractionManager handle for the entirety of each animation #2434

Closed
@almost

Description

@almost
Contributor

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:

  1. 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.
  2. 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.
  3. 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?

Activity

ide

ide commented on Aug 25, 2015

@ide
Contributor

@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.

changed the title [-]Animated: Holds a InteractionManager handle for the entirety of each animation[/-] [+][Animated] Holds a InteractionManager handle for the entirety of each animation[/+] on Aug 25, 2015
aleclarson

aleclarson commented on Sep 3, 2015

@aleclarson
Contributor

+1

idibidiart

idibidiart commented on Nov 23, 2015

@idibidiart

+1

ide

ide commented on Nov 23, 2015

@ide
Contributor

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.

locked as resolved and limited conversation to collaborators on Jul 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @almost@ide@idibidiart@aleclarson@react-native-bot

        Issue actions

          [Animated] Holds a InteractionManager handle for the entirety of each animation · Issue #2434 · facebook/react-native