Skip to content

Commit

Permalink
PanResponder should not hold stale handle for interaction.
Browse files Browse the repository at this point in the history
Summary:
For now, `PanResponder.create()` return a new object which may hold a handle
for interaction. The handle is created when the gesture starts, and it's cleared
when the gesture finishes.

However, the handle may become stale cause the owner (view) is removed or
re-rendered before the gesture finishes, which leaves InteractionManager
with handles that can never be removed.

In some cases, this blocks the app that waits for InteractionManager to
be idle and having leaky handles prevents InteractionManager from being idle
again.

The fix is to move the handle from the instance to the static variable, and
we'd clear it whenever a gesture finishes.

Reviewed By: sahrens

Differential Revision: D3550699

fbshipit-source-id: 412e9046a6cd9be34b3a7d572258008016a29f41
  • Loading branch information
Hedger Wang authored and Facebook Github Bot committed Jul 15, 2016
1 parent 6eb318d commit 4843a90
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Libraries/Interaction/PanResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,12 @@ const PanResponder = {
config.onPanResponderTerminationRequest(e, gestureState);
}
};
return { panHandlers: panHandlers };
return {
panHandlers,
getInteractionHandle(): ?number {
return interactionState.handle;
},
};
}
};

Expand Down

0 comments on commit 4843a90

Please sign in to comment.