From 4843a90c1c6956271a23c34f026c71a65a4fceec Mon Sep 17 00:00:00 2001 From: Hedger Wang Date: Fri, 15 Jul 2016 11:45:34 -0700 Subject: [PATCH] PanResponder should not hold stale handle for interaction. 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 --- Libraries/Interaction/PanResponder.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Libraries/Interaction/PanResponder.js b/Libraries/Interaction/PanResponder.js index 713e3840ae..0692ffbfcb 100644 --- a/Libraries/Interaction/PanResponder.js +++ b/Libraries/Interaction/PanResponder.js @@ -388,7 +388,12 @@ const PanResponder = { config.onPanResponderTerminationRequest(e, gestureState); } }; - return { panHandlers: panHandlers }; + return { + panHandlers, + getInteractionHandle(): ?number { + return interactionState.handle; + }, + }; } };