-
Notifications
You must be signed in to change notification settings - Fork 35
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
Cronet with Retrofit is crashing due to file-descriptor leaks #15
Comments
Thanks for the feedback. Using the sample app, and the following command on an ADB root shell: for fd in /proc/$(pidof com.google.samples.cronet.okhttptransport)/fd/*; do readlink "$fd"; done | sort FD counts:
4 additional FDs when sending requests using pure OkHttp:
20 additional FDs when initializing Cronet:
2 additional FDs when sending requests through Cronet:
So using Cronet results in 18 additional FDs being used, compared to pure OkHttp. I also looked at the number of FDs being opened per contacted destination domain, but I couldn't find a clear regression between pure OkHttp and Cronet-backed OkHttp in that regard - they both seem to use 1 to 2 FD per destination domain. To clarify, is it the 20 FDs fixed cost from Cronet initialization that's bothering you or are you observing behavior that isn't covered in the above? |
I think it depends on the number of requests per app. |
I've tried issuing 1k concurrent OkHttp requests to the top 1k websites as indicated by this list: https://gist.github.com/bejaneps/ba8d8eed85b0c289a05c750b3d825f61. Like Etienne, I haven't experienced any issues with the setup and the number of open descriptors looks roughly consistent as the requests re being processed, with the exception of Cronet being a bit more aggressive with keeping them open towards the end. This was using the default Pixel 6 emulator with Android 13. If you can reliably reproduce the issue in a sandbox setup repro steps would be much appreciated. |
@Danstahrg can you please share the sample app code for that 1k requests test? |
Before enabling Cronet with Retrofit using above snippet, make sure to chek the file-descriptor count, via:
adb shell
su
ls -l /proc/$(pidof APP_PACKAGE_NAME)/fd | wc
[we're interested in the first value]Running the same commands again, after we enable Cronet with Retrofit almost doubled the number of opened file descriptors for my app, which on some devices is causing a crash, since it hits the limit per one app.
The text was updated successfully, but these errors were encountered: