-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Swizzle RCTEventDispatcher #4576
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
piaskowyk
approved these changes
Jun 16, 2023
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.
👍
tomekzaw
added a commit
that referenced
this pull request
Jun 19, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR fixes a typo introduced by me in #4576. ## Test plan <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. -->
Latropos
pushed a commit
that referenced
this pull request
Jun 20, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary Reanimated needs to intercept events while still on the UI thread. To achieve this on iOS, currently we overwrite the instance of `RCTEventDispatcher` with an instance of `REAEventDispatcher` which extends `RCTEventDispatcher` but overrides `sentEvent` method. We need to overwrite event dispatcher as soon as possible, i.e. before native modules are initialized, so that `RNGestureHandlerManager` holds an already overwritten instance (see [here](https://github.com/software-mansion/react-native-gesture-handler/blob/9a3b90df0df3e7f85bb06ae7946aea3be95f717c/ios/RNGestureHandlerManager.mm#L62)). Currently, we call `REAInitializer` in `jsExecutorFactoryForBridge` method. This PR removes some dirty initialization code and uses swizzling instead to achieve the same effect. <img width="1496" alt="screenshot" src="https://github.com/software-mansion/react-native-reanimated/assets/20516055/86ed7bec-b40a-4f2a-a29a-9e72f511e77e"> ## Test plan 1. Build Example app on iOS 2. Check scroll- and gesture-based examples
Latropos
pushed a commit
that referenced
this pull request
Jun 20, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR fixes a typo introduced by me in #4576. ## Test plan <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. -->
3 tasks
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jul 7, 2023
## Summary Recently, we began rewriting the iOS initialization process. Tomek moved the injection of JSI bindings to `installTurboModule` (check out #4523) and then used swizzling to eliminate the `REAEventDispatcher` (see #4576). More context here: expo/expo#23057 (comment) This PR removed UIManager overriding by swizzling the `_manageChildren` and `uiBlockWithLayoutUpdateForRootView` methods. These changes allowed us to get rid of `RCTAppDelegate+Reanimated`, `UIResponder+Reanimated`, and `REAInitializer`. For now, we're gonna leave `REAInitializer` as deprecated for a few more releases to maintain backward compatibility. But just a heads up, we'll be removing it in the future. ## Test plan - I tested building on different react native versions by CI https://github.com/piaskowyk/reanimated-rn-version-tester/actions/runs/5375166823 - Tested Layout Animations on Example app form main branch.
Latropos
pushed a commit
that referenced
this pull request
Jul 13, 2023
## Summary Recently, we began rewriting the iOS initialization process. Tomek moved the injection of JSI bindings to `installTurboModule` (check out #4523) and then used swizzling to eliminate the `REAEventDispatcher` (see #4576). More context here: expo/expo#23057 (comment) This PR removed UIManager overriding by swizzling the `_manageChildren` and `uiBlockWithLayoutUpdateForRootView` methods. These changes allowed us to get rid of `RCTAppDelegate+Reanimated`, `UIResponder+Reanimated`, and `REAInitializer`. For now, we're gonna leave `REAInitializer` as deprecated for a few more releases to maintain backward compatibility. But just a heads up, we'll be removing it in the future. ## Test plan - I tested building on different react native versions by CI https://github.com/piaskowyk/reanimated-rn-version-tester/actions/runs/5375166823 - Tested Layout Animations on Example app form main branch.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Reanimated needs to intercept events while still on the UI thread. To achieve this on iOS, currently we overwrite the instance of
RCTEventDispatcher
with an instance ofREAEventDispatcher
which extendsRCTEventDispatcher
but overridessentEvent
method. We need to overwrite event dispatcher as soon as possible, i.e. before native modules are initialized, so thatRNGestureHandlerManager
holds an already overwritten instance (see here). Currently, we callREAInitializer
injsExecutorFactoryForBridge
method. This PR removes some dirty initialization code and uses swizzling instead to achieve the same effect.Test plan