Why JSON serialization over the asynchronous bridge created UI stutter, and how JSI exposes direct C++ memory pointers.
The Legacy Bridge is like mailing paper letters back and forth across a postal sorting office to coordinate a dance routine. JSI is holding hands with your dance partner and communicating muscle movements instantly in real-time.
Legacy: JS thread serializes UI mutation into JSON payload [tag, method, args]
Legacy: Message waits in asynchronous bridge message queue (batched every 5ms)
Legacy: Native thread parses JSON and applies layout changes (causing gesture lag)
JSI New Architecture: Hermes JS engine instantiates a C++ HostObject
JSI: JavaScript invokes hostObject.invokeMethod() directly in a synchronous C++ call stack
// JSI C++ HostObject Invocation (Zero Serialization)
class NativeMathHostObject : public jsi::HostObject {
public:
jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override {
auto propName = name.utf8(runtime);
if (propName == "fastMultiply") {
return jsi::Function::createFromHostFunction(
runtime, name, 2,
[](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
double a = args[0].asNumber();
double b = args[1].asNumber();
return jsi::Value(a * b); // Direct synchronous C++ return!
}
);
}
return jsi::Value::undefined();
}
};JSI allows direct ArrayBuffer byte sharing between JavaScript and C++ without copying or JSON encoding, enabling 120 FPS camera filters.