We have recently switched from OkHttp2 to OkHttp3 and upgraded to NewRelic Agent 5.9 for Android. We have some code that is using the OkHttp3’ HttpURLConnection interface to perform downloads. After the switch we noticed that the download progress was no longer reported linearly throughout the download. Instead, the download was stuck at 0% for a long time before going to 100% instantly.
After some debugging, we have traced the source of this issue to New Relic’s OkHttp3 instrumentation. Specifically, NewRelic injects OkHttp3 interceptors that prebuffer the response body stream. The classes responsible for this behavior are ResponseBuilderExtension and PrebufferedResponseBody in the NewRelic instrumentation.
Can you update your instrumentation code to avoid pre-fetching the entire response body stream? The existing behavior limits the use of OkHttp3 for streaming applications like downloads and potentially also uses a large amount of memory to buffer and prefetch the data.