-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Ktor native client fields are frozen #1537
Comments
It looks like a byte channel is frozen for some reason in spite of that it is running in the main dispatcher. |
Some folks helped me out on the kotlin slack. Based on discussions there I think this is really a case for the kotlin native concurrency documentation to be improved. I opened a ticket there |
It's a little more complicated. I've been meaning to comment on the coroutines PR, as I think this is more of an issue for the coroutines implementation. Here's a minimal failing example: fun goMain() = mainScope.launch {
val result = withContext(Dispatchers.Main){
SomeData2("236")
}
println("Result from main $result isFrozen ${result.isFrozen}")
}
fun goBackground() = mainScope.launch{
val result = withContext(Dispatchers.Default){
SomeData2("125")
}
println("Result from default $result isFrozen ${result.isFrozen}")
}
data class SomeData2(val s:String) From iOS, if you call To work around this, I create 2 scopes for the coroutines. One that does background thread stuff, and one for ktor. internal val mainScope = MainScope(Dispatchers.Main)
internal val ktorScope = MainScope(Dispatchers.Main) I would think coroutines should act consistently (IE not freeze same-thread, or always freeze). I would also add |
Ktor Version and Engine Used (client or server and name)
kotlin_version=1.3.61
ktor_version=1.3.0-rc2
coroutines_version=1.3.3-native-mt
Describe the bug
Calling testNetworkCall() on iOS leads to a kotlin.native.concurrent.InvalidMutabilityException
Full stacktrace from native
I think it is because singletons are by default frozen, so any singleton without the @ThreadLocal annotation will freeze objects it references.
To Reproduce
Copy and paste the code snipped above into a multiplatform project. Run the function from the iOS app.
Expected behavior
We should be able to make an http request without the mutability exception being thrown.
Screenshots
No screenshot to attach.
The text was updated successfully, but these errors were encountered: