perf: Set isDirty to false to avoid JNI roundtrips#1195
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Closed
4 tasks
This file contains hidden or 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
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.
On iOS we had an optimization mechanism to set a flag called
isDirtytofalseafter a prop change has been applied to a Nitro View, causing the next prop update to only parse/set the props that have actually changed, and leave unchanged props untouched.For views with a lot of props, this can save thousands of CPU cycles as these three steps:
jsi::Valueto a C++ value...are all skipped.
On Android, this wasn't so simple - I had to create a react-native PR a few months ago, which luckily is now live in RN 79/80.
Now we can get a
shared_ptrto the Props, allowing us to modify them (even if it looks unsafe), so this PR now brings this performance optimization to Android too - which should have an even greater impact since a JNI call is much more expensive than the virtual method call to swift.So now this works on both platforms :)