-
-
Notifications
You must be signed in to change notification settings - Fork 1k
[General] Reduce number of created closures #3853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
packages/react-native-gesture-handler/src/v3/hooks/callbacks/stateMachine.ts
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts
Outdated
Show resolved
Hide resolved
| event.state !== event.oldState | ||
| ) { | ||
| if (event.oldState === State.ACTIVE) { | ||
| runCallback(CALLBACK_TYPE.END, callbacks, event, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not in this PR, but we should rename START, END callbacks
packages/react-native-gesture-handler/src/v3/hooks/callbacks/stateMachine.ts
Outdated
Show resolved
Hide resolved
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have handleTouchEvent, maybe we should also handleUpdateEvent and handleStateChangeEvent?
Beside that looks good.
| } | ||
| } | ||
|
|
||
| export function handleUpdate<THandlerData>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export function handleUpdate<THandlerData>( | |
| export function handleUpdateEvent<THandlerData>( |
| import { TouchEventType } from '../../../TouchEventType'; | ||
| import { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; | ||
|
|
||
| function handleStateChange<THandlerData>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| function handleStateChange<THandlerData>( | |
| function handleStateChangeEvent<THandlerData>( |
Description
I noticed that
useGestureCallbacksstill took significant time to run, despite not doing that much. I narrowed it down to the fact that it created a lot of closures for different events, while we only need two: one for JS and the other for Reanimated.This PR refactors how the state machine is created for gestures to reduce the number of closures created to 2 per
useGestureCallbackscall.Test plan
Tested on the stress-test