envoyproxy / envoyproxy/envoy-mobile
Extra ByteBuffer copy when reading the response body
- Dominant language
- Java
- Stars
- 566
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
One Native Cronet "read" method is this one:
```
boolean readData(
long nativePtr,
CronetBidirectionalStream caller,
ByteBuffer byteBuffer,
int position,
int limit);
```
The Caller provides the ByteBuffer and specifies which section is allowed to read next chunk of data from the Response Body. This Native Cronet method is **not blocking**: a callback method is invoked once the data is ready.
With Envoy-Mobile, the Caller does not provide a ByteBuffer - Envoy-Mobile itself provides a new DirectByteBuffer through the callback method `EnvoyHTTPCallbacks.onData(ByteBuffer data, boolean endStream)`.
Therefore, the Cronvoy implementation incurs an extra ByteBuffer copy: the caller did provide a ByteBuffer, and the data read is in another ByteBuffer, created by Envoy-Mobile.
This might be detrimental for Android Devices constrained by I/O RAM. Should this be addressed?
Contributor guide
Assessment
This issue has not been assessed yet.