Open mrousavy opened 1 month ago
It works!!! 🥳
So now it works (finally! 🥳), but the performance improvements are in the 5%-10% area, which is less than I hoped for.
We can still optimize a few things like trying to construct JString
without std::string
... I'll look into that.
Strings in Kotlin got a bit faster though:
The performance improvements are much less than what I originally anticipated. It seems like Nitro was already really fast on Android.
Going directly to JNI didn't really give any benefits other than a 20% speed improvement for Strings, but the rest roughly stayed the same as the C++ layer is so efficient already.
Also, with this PR the complexity of Kotlin HybridObjects greatly increased, because every property and method got generated twice - once for Kotlin (JNI <> JS), and once for C++ (JNI <> C++, to provide access to C++ if needed). This is very complex and potentially error prone.. Not sure if it's a good decision to do that.
I'll profile and investigate more on this, and think about if the added complexity in the code-generator CLI is worth the small performance improvements here.
Before, a Java/Kotlin HybridObject always went through C++/std types, even if we discarded them right away since we pass them to Java.
For example, for Arrays this looked like this:
Now with this PR, we generate bindings directly to JSI:
This is much more efficient, especially for Arrays, as we completely avoid C++/std types.
Additionally, since every HybridObject is a C++ object at it's base (since we also want to be able to use Kotlin/Swift types from C++ as if it was any conventional C++ class), we also need to generate bindings to C++:
This looks like this in a HybridObject: