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

Should SSLContext construction be deferred during OkHttpClient construction #8231

Open
yschimke opened this issue Jan 31, 2024 · 2 comments · May be fixed by #8248
Open

Should SSLContext construction be deferred during OkHttpClient construction #8231

yschimke opened this issue Jan 31, 2024 · 2 comments · May be fixed by #8248
Labels
enhancement Feature not a bug

Comments

@yschimke
Copy link
Collaborator

https://www.zacsweers.dev/dagger-party-tricks-deferred-okhttp-init/

OkHttpClient initialization can take upwards of 100ms on some Android devices in the wild due to its use of TrustManagerFactory. Initializing the Cache is also not free, as it creates an internal Executor and may incur some disk IO if you want to prepare a cache directory for it first.

@yschimke yschimke added the enhancement Feature not a bug label Jan 31, 2024
@yschimke yschimke linked a pull request Feb 10, 2024 that will close this issue
@swankjesse
Copy link
Member

Is the best solution to make OkHttp lazy internally? Or to encourage our users to instantiate their OkHttp clients lazily? I think making OkHttp lazy potentially introduces other problems by deferring failures

@yschimke
Copy link
Collaborator Author

yschimke commented Apr 3, 2024

I'm not sure. But it's

A) a real problem
B) the default behaviour and common.
C) something we put on every developer to do if we don't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature not a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants