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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OkHttp inspector hangs on big uploads #329

Closed
evgeny-sureev opened this issue Jan 17, 2016 · 7 comments
Closed

OkHttp inspector hangs on big uploads #329

evgeny-sureev opened this issue Jan 17, 2016 · 7 comments

Comments

@evgeny-sureev
Copy link

My app uploads photos taken from camera. If upload request appears on log, Chrome hangs completely. I think this happens because inspector tries to dump raw jpeg content to Headers tab.

@jasta
Copy link
Contributor

jasta commented Jan 19, 2016

This is due to a very unfortunate limitation in the inspector protocol which appears to require that we serialize request payloads as UTF-8 strings and upload them to the UI. I know of no way around this other than to perhaps upgrade to a newer version of the protocol (which I haven't evaluated in ~6 months) or to simply detect large payloads and omit them when reporting the request.

I tried for a while to figure out what current Chrome upstream does when uploading large images but for reasons I forget now couldn't seem to repro this issue. If you're feeling motivated, you could raelly help speed this up by connecting Chrome for Android to Chrome on your PC/laptop (chrome://inspect just like with Stetho, find your Chrome for Android instance and click Inspect), then try to get Chrome for Android to upload a very large payload to a server and capture what the inspector does. In either case (it does what you want or not) could you take a screenshot for us and we'll see what we can do?

@evgeny-sureev
Copy link
Author

It seems that Chrome omits large payloads:

screenshot

This is from stetho with image displayed as raw content:

example

With small sized images inspector just slow down, so I am able to capture screenshot. When image size exceed 1 Mb, inspector stop responding.

@jasta
Copy link
Contributor

jasta commented Jan 24, 2016

I think the right thing to do then would be to detect large payloads and simply omit them from the payload string. If you're interested in taking a crack at this, it should be a simple matter of applying this heuristic in NetworkEventReporterImpl.java:readBodyAsString. Because this method sees the decompressed body, it should be safe to simply look for binary and/or very large payloads and replace those payloads with something else.

Also note that it's possible to do an even better job filtering this out for StethoInterceptor because it can detect a multi-part request body and inspect the content-type of each part individually to determine what it should report. But if you don't do this carefully you will end up causing the "request size" field to not be computed correctly.

@jasta
Copy link
Contributor

jasta commented Jun 2, 2016

Closing due to inactivity, though I'm still very interested in having this issue solved. I just doubt I'll personally have time unless I hit this issue in one of my apps (which, I guess, is Facebook for Android hehe)

@jasta jasta closed this as completed Jun 2, 2016
@sudhirkhanger
Copy link

How are you not hitting this issue? Anytime the POST request fails the inspector will try to load image in it and freeze.

@thebehera
Copy link

thebehera commented Sep 15, 2017

i believe i have fixed the bug here, #564 should fix it
for now you can add any of these to your gradle to test

com.github.thebehera.stetho:stetho-timber:d603cf381e
com.github.thebehera.stetho:stetho-js-rhino:d603cf381e
com.github.thebehera.stetho:stetho-okhttp:d603cf381e
com.github.thebehera.stetho:stetho:d603cf381e
com.github.thebehera.stetho:stetho-urlconnection:d603cf381e

@DavidJRobertson
Copy link

I am still encountering this issue with image uploads using version 1.5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants