Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chucker corrupts image resources. #225

Closed
MiSikora opened this issue Feb 3, 2020 · 5 comments 路 Fixed by #226
Closed

Chucker corrupts image resources. #225

MiSikora opened this issue Feb 3, 2020 · 5 comments 路 Fixed by #226

Comments

@MiSikora
Copy link
Contributor

MiSikora commented Feb 3, 2020

馃摙 Describe the bug

If OkHttp client with the ChuckerInterceptor is used for image downloads then the requests fail.

馃挘 To Reproduce

  1. Run the sample project. - https://github.com/MiSikora/Chucker-Bug
  2. Run the app.
  3. Select the check box to enable Chucker.
  4. Press either Coil or Picasso buttons.

馃敡 Expected behavior

The image should be downloaded and displayed in the ImageView. It should work in the same way as if the ChuckerInterceptor was disabled.

馃摲 Screenshots

Stack trace for Picasso.

java.io.IOException: Failed to decode stream.
  at com.squareup.picasso.BitmapHunter.decodeStream(BitmapHunter.java:161)
  at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:229)
  at com.squareup.picasso.RequestCreator.get(RequestCreator.java:429)
  at io.mehow.demo.MainActivity$onCreate$3$1.invoke(MainActivity.kt:54)
  at io.mehow.demo.MainActivity$onCreate$3$1.invoke(MainActivity.kt:23)
  at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

Stack trace for Coil.

java.lang.IllegalStateException: BitmapFactory returned a null Bitmap. Often this means BitmapFactory could not decode the image data read from the input source (e.g. network or disk) as it's not encoded as a valid image format.
  at coil.decode.BitmapFactoryDecoder.decode(BitmapFactoryDecoder.kt:156)
  at coil.RealImageLoader$loadData$2.invokeSuspend(RealImageLoader.kt:392)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:561)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:727)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:667)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:655)

馃摫 Smartphone

  • Device: Any Device
  • OS: Any OS
  • Lib version: 3.1.1

馃搫 Additional context

Issue does not exist in 3.1.0. It was introduced with 3.1.1.

@vbuberen
Copy link
Collaborator

vbuberen commented Feb 3, 2020

Hi @MiSikora
Thanks for your report and for the sample, but, please, next time provide samples without preview features, like view binding, since, for example, I don't have 3.6 RC02, but only 3.5.3 and 4.0 canary 9, both of which don't know what view binding is.

@vbuberen vbuberen added the bug Something isn't working label Feb 3, 2020
@MiSikora
Copy link
Contributor Author

MiSikora commented Feb 3, 2020

Hi @vbuberen
Android Studio Canary 9 has ViewBinding. You need to enable it in a different way.

android {
  buildFeatures {
    viewBinding = true
  }
}

Or via Gradle properties.

https://developer.android.com/studio/preview/features#buildfeatures

@vbuberen
Copy link
Collaborator

vbuberen commented Feb 3, 2020

Thanks for pointing out. Didn't know that :)
Debugging the problem now and see that there is an issue with response processing.
Here is how response content looks like before reaching processReponse()
Before processing
And here is after:
After
Going to try my solution of creating copy for processing and returning original response further the chain. I wanted to use it in 3.1.1, but another solution from @cortinico was ready and worked better at that moment.

@MiSikora
Copy link
Contributor Author

MiSikora commented Feb 3, 2020

Cool, thanks for the quick response.

If copying is a to go solution maybe you could try to play around tee command - square/okio#186

I don't know if that's helpful. I might give it a stab when I find some time.

@cortinico
Copy link
Member

Thanks for reporting and thanks for providing also a reproducible environemtn @MiSikora.

Going to try my solution of creating copy for processing and returning original response further the chain.

Let me know if you do any progress on this side @vbuberen

I don't know if that's helpful. I might give it a stab when I find some time.

If you happen to have time for this, we would really appreciate your contribution :)

@ghost ghost added the Pending PR The resolution for the issue is in PR label Feb 8, 2020
@ghost ghost removed Pending PR The resolution for the issue is in PR bug Something isn't working labels Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants