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
This commit is contained in:
Hedger Wang 2016-07-15 11:45:34 -07:00 committed by Facebook Github Bot
parent 6eb318d87d
commit 4843a90c1c
1 changed files with 6 additions and 1 deletions

View File

@ -388,7 +388,12 @@ const PanResponder = {
config.onPanResponderTerminationRequest(e, gestureState);
}
};
return { panHandlers: panHandlers };
return {
panHandlers,
getInteractionHandle(): ?number {
return interactionState.handle;
},
};
}
};