Does the normal version of Ktor support the new Ko...
# ktor
r
Does the normal version of Ktor support the new Kotlin Native Memory Management Model from 1.6.3+? I don’t see anything in the changelog
b
What do you mean by normal?
r
As opposed to the eap 1.6.2 version which was specifically made for the new memory model, after that I can’t find anything about it in subsequent versions
b
Are you talking about ktor client?
r
Well yeah in my case
But you can also use the server in K/N so it shouldn’t matter
b
I think you should be fine with new mm. Ktor server in k/n is not released yet and will only come with 2.0
r
Thanks, I’ll try the new mm then
m
I am trying to make the 2.0 client work with new memory model and having some troubles. Right now it's
InvalidMutabilityException: mutation attempt of frozen kotlin.Array@249bab0
in
kfun:io.ktor.client.plugins.json.serializer.SerializerInitializer.<init>#internal + 236
. (trying to install kotlinx serialization into ktor) Using coroutines 1.6.0-native-mt fwiw (in regular 1.6.0 had other issues). (works without new-mm flag)
r
I’m pretty sure coroutines
1.6.0-native-mt
isn’t meant to work with the new memory model
h
Coroutines
1.6.0-native-mt
works with the new MM. Problems are external dependencies, like
io.ktor.client.plugins.json
, which uses a shared Json instance
m
I put my own Json instance to the plugin. This happens at the very startup of the app, the first time the ktor client is created with the json plugin. Any hints what can be done about it?
m
🤔 I'm not using the defaults so that should not affect my code.
okay so I fixed it by removing
Copy code
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
from my iosMain source set (was left after migration to ktor 2.x). But now I have
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen io.ktor.client.engine.engines.Node@3d40580
😄
okay, so the thing that fixes ktor and a few other things for me is
kotlin.native.binary.freezing=disabled
in
gradle.properties
a
What exact version of Ktor do you use?
m
2.0.0-beta-1