-
Notifications
You must be signed in to change notification settings - Fork 32
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
FreezingException when using Main dispatcher #10
Comments
Hey! Will have to take a closer look at this but I think the issue is in the suspend function. The difference with the original repo is that it uses a Did you already try using the |
Thanks for the quick response! Yes using I added the following to val characterPagerFlow: Flow<PagingData<CharacterDetail>>
get() = characterPager.pagingData.cachedIn(scope) And creating the publisher from NativeFlow:
Crash:
Pushed a new commit with NativeFlow: ychescale9/MortyComposeKMM@21a3e6f |
Alright there are a couple of things going on here. First of all you are using Then there are actually 2 freezing issues (one with apollo3 and another with the multiplatform pager). This means the The Apollo code is calling But that brings me to the second freezing issue where the pager is trying to add items to a frozen list.
Changing the pager to only use the StateFlow with immutable lists should fix this. FYI both issues can be reproduced without KMP-NativeCoroutines by manually freezing the // commonMain
expect fun <T> T.freeze(): T
class MortyRepository {
// this should be at the bottom of the MortyRepository
init {
freeze()
}
}
// iosMain
actual fun <T> T.freeze(): T = freeze()
// androidMain
actual fun <T> T.freeze() = this |
I have created issues for both the Apollo and Pager libraries. |
Thanks for the thorough investigation and creating those issues! 🙏 |
👋
I'm running in to a
FreezingException
when integrating NativeCoroutines with Apollo3 which requires queries to be launched fromMain
dispatcher.I couldn't reproduce it without apollo3 so I forked https://github.com/joreilly/MortyComposeKMM which is using Apollo3.
This is my branch with the crash: https://github.com/ychescale9/MortyComposeKMM/tree/reproduce-crash-with-NativeCoroutines-integration
This is the diff: ychescale9/MortyComposeKMM@dd65771#diff-c16bdea5c96b86a9098c45a11157d0a6f14338e025e52ca682b7753ccea205b2
Crash:
This original repo is using this (which uses this dispatcher implementation) which seems to work.
The text was updated successfully, but these errors were encountered: