Transferring large buffer between native and JS is too slow

Trying to send 54MB text data between native and JS (using cordova plugin) takes around 3 seconds on iPhone6. And it takes around 5 seconds to send same 54 MB data back from JS to Native. This is with wkwebview.

Has anyone tried transferring large amount of data between Native and WebView? Any ideas on why its so slow and what else can be tried that can be faster?

I was hoping it shouldn’t take more than 50-100 ms just to copy over a buffer, 3-5 seconds is way too slow to be usable. My guess is that it could be due to evaluateJavaScript trying to ‘compile’ the 54 MB string, even though its all in “quotes” in a JSON object. It is even more surprising why didReceiveScriptMessage would take even longer.

Any clues, suggestions, ideas etc will really help - How to transfer 100 MB+ data super fast between native and JS layers?

Hi @schngrg :wave:

I’m not sure if Cordova’s bridge was designed for this kind of data size :sweat_smile:

Have you tried Capacitor? Being more modern and having some optimizations, it may be more performant (haven’t tried passing big payloads though). Since it supports both plugins, you can either use Cordova plugins or write your own Capacitor plugin, which may run faster.


Both capacitor and cordova internally use wkwebview and most likely its evaluateJavaScript and didReceiveScriptMessage APIs. The slowness is not because of cordova but because these wkwebview APIs are too slow.

Or does capacitor use some other method for transferring data between JS and native code? Like maybe an internal webserver?

I don’t know about the specific implementation details. Try contacting Julio (@jcesarmobile) from the Ionic team, maybe he can give some pointer about what may be happening :wink: