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

User Class.forName instead of ServiceLoader to instantiate Dispatchers.Main on Android #1572

Merged
merged 2 commits into from
Dec 12, 2019

Conversation

qwwdfsad
Copy link
Collaborator

ServiceLoader has proven itself as a very unstable mechanism on Android (see all the issues in a loadMainDispatcherFactory comment). Moreover, failures in SL are considered by kotlinx.coroutines users as errors in the library itself, making it look unstable. We are not really happy with that, so here is an attempt to avoid ServiceLoader on Android for Dispatchers.Main.

Though I am not sure whether this change should be merged in kotlinx.coroutines. Moreover, I am not sure how exactly to evaluate the potential impact of this change.
@wojtek-kalicinski and @JakeWharton could you please help with reviewing this change first?

Fixes #1557
Fixes #878

@wojtek-kalicinski
Copy link
Contributor

In principle it looks good. I'm wondering if you then still want to have the R8-specific assumenosideeffects class kotlinx.coroutines.internal.MainDispatcherLoader { boolean FAST_SERVICE_LOADER_ENABLED configs... unless you treat them as fallback in case Class.forName fails, though I'm not sure if that would ever happen

@qwwdfsad qwwdfsad force-pushed the android-service-loader branch 2 times, most recently from 98dbf26 to 7a625e8 Compare October 21, 2019 16:00
@qwwdfsad qwwdfsad requested a review from elizarov October 21, 2019 16:00
Copy link
Contributor

@elizarov elizarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qwwdfsad qwwdfsad force-pushed the android-service-loader branch from 41281e5 to cf9fc1a Compare October 30, 2019 09:22
@qwwdfsad qwwdfsad merged commit e60ec8e into develop Dec 12, 2019
@qwwdfsad qwwdfsad deleted the android-service-loader branch December 12, 2019 09:10
yamasa added a commit to line/lich that referenced this pull request Jan 10, 2020
FastServiceLoader has been fixed in Kotlin Coroutines 1.3.3, so we no longer
need to disable it.
cf. Kotlin/kotlinx.coroutines#1572
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 this pull request may close these issues.

4 participants