How can I transfer the binary data obtained by the web end via socket.io to the Android native layer? #8254
Replies: 1 comment
|
I checked webView.addJavascriptInterface(this, "androidBridge");
// ...
@JavascriptInterface
public void postMessage(String jsonStr) { /* ... */ }The entire JS-to-native channel for plugin calls is a single For 30fps binary streaming this is the wrong path entirely. The approach that actually gets you real throughput is bypassing the Capacitor plugin bridge for this hot path: terminate the socket.io connection natively (there's a mature Java/Kotlin socket.io client) inside a custom plugin, and hand frames to your native processing/rendering code directly without ever marshalling them back through |
Uh oh!
There was an error while loading. Please reload this page.
I have checked the source code, and it is necessary to transmit strings to the native layer. However, this will affect my efficiency. For the binary stream pushed by socket.io at 30fps, I have to convert it to base64 for transmission, and then convert it back from base64 in the native layer. As a result, from the time-consuming statistics log, I found that the round-trip conversion time for the binary data of each frame fails to meet the expected requirement.
All reactions