Skip to content

perf: Set isDirty to false to avoid JNI roundtrips#1195

Merged
mrousavy merged 7 commits intomainfrom
fix/fix-isdirty-android
Feb 3, 2026
Merged

perf: Set isDirty to false to avoid JNI roundtrips#1195
mrousavy merged 7 commits intomainfrom
fix/fix-isdirty-android

Conversation

@mrousavy
Copy link
Owner

@mrousavy mrousavy commented Feb 3, 2026

On iOS we had an optimization mechanism to set a flag called isDirty to false after 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:

  • Parsing the jsi::Value to a C++ value
  • The virtual method call to Swift
  • Parsing the C++ value to a Swift 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_ptr to 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 :)

@vercel
Copy link

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
nitro-docs Skipped Skipped Feb 3, 2026 11:26am

Request Review

@mrousavy mrousavy merged commit 67d45a4 into main Feb 3, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android HybridView: isDirty flag not reset after prop update causes unnecessary JNI calls

1 participant