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

ServiceLoader is very, very expensive on Android, please just crash instead #1

Closed
LouisCAD opened this issue Aug 12, 2024 · 2 comments · Fixed by #2
Closed

ServiceLoader is very, very expensive on Android, please just crash instead #1

LouisCAD opened this issue Aug 12, 2024 · 2 comments · Fixed by #2

Comments

@LouisCAD
Copy link

Hi, if you dig into kotlinx.coroutines issues about ServiceLoader, you will see it's unfortunately very expensive on Android. Probably best to stick to build-time only behavior, or implement a custom, cheaper and R8 safe way to do what ServiceLoader does.

@whyoleg
Copy link
Owner

whyoleg commented Aug 12, 2024

Hey! yeah, that's unfortunate and would be nice to have. As far as I understand, R8 can transform specific calls in a form of:
ServiceLoader.load(X.class, X.class.getClassLoader()).iterator() (source)
So probably it's doable. Would be nice to hear on how to better test it.

@whyoleg
Copy link
Owner

whyoleg commented Aug 12, 2024

FYI, I was able to test and fix the performance of ServiceLoader on Android (for most cases I believe?)
I don't have real device at my side, but I do believe that there should be no difference

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.

2 participants