google/cronet-transport-for-okhttp

Cronet request lifecycle not triggerred as expected when using apollographql/apollo-kotlin`

Opened this issue · 0 comments

I've adapted https://github.com/apollographql/apollo-kotlin-tutorial to use https://github.com/google/cronet-transport-for-okhttp (https://github.com/duzinkie/apollo-kotlin-tutorial/tree/duzinkie/cronet-lifecycle-repro) and have observed the app is not functioning correctly when Cronet is used as an http engine.

Let me elaborate:
The app built from https://github.com/duzinkie/apollo-kotlin-tutorial/tree/duzinkie/cronet-lifecycle-repro is working fine, until one tries to adjust the logging level of HttpLoggingInterceptor (duzinkie/apollo-kotlin-tutorial@9b3e58a#diff-518bd35be782210b23f518eaf618c538f99e9f33a81f6b518ccb053b4315eff1R94) - when that happens 2 distinct failure modes occur, depending on whether http batching is enabled.

  1. if batching is enabled: duzinkie/apollo-kotlin-tutorial@9b3e58ab1d - cronet engine does not call the method attached to it in the request finished listener in duzinkie/apollo-kotlin-tutorial@9b3e58a#diff-518bd35be782210b23f518eaf618c538f99e9f33a81f6b518ccb053b4315eff1R48
  2. if batching is not enabled - all the requests are considered cancelled (although from the UI point of view - everything seems to be functioning just fine (app is responsive, renders fetched data etc)

Steps to reproduce the behavior

  1. Clone https://github.com/duzinkie/apollo-kotlin-tutorial/tree/duzinkie/cronet-lifecycle-repro
  2. Build the app, interact with it, observe it's working fine, and logs contain GQL calls as well as cronet request finished: 0 lines from the cronet http engine (indicating requests are finishing just fine)
  3. Adjust Apollo.kt file in the cloned project:
    a. change the logging level of HttpLoggingInterceptor to BASIC
    b. disable httpBatching
  4. Observe the app behavior and logs in both 3a and 3b cases:
  • in 3a - cronet request finished messages are absent and the app hangs after a few interactions
  • in 3b - all requests are marked as cancalled (as indicated by cronet request finished: 2 log messages

Side-notes:

  • This is a sibling issue to apollographql/apollo-kotlin#5885 (in fact most the content here is copy pasted)
  • I've created #36 before, but I do not know if those are related (that earlier issue regards sending requests, this one occurs when receiving responses, they could hare a root cause but idk at the moment)