You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i use kotlinx-io not directly - just by ktor. My project is mobile app with shared library for ios & android, when i send very large textcontent by ktor (4mb photo from ios device encoded by base64) app stuck on call kotlinx.io.core.toByteArray and worked with 100% cpu usage by 30mins, and after it request is done and all complete. For fast fix i create my own TextContent, which use not kotlinx.io.core.toByteArray, but kotlinx.serialization.toUtf8Bytes on iOS platform. Here code:
class LargeTextContent(
val text: String,
override val contentType: ContentType,
override val status: HttpStatusCode? = null
) : OutgoingContent.ByteArrayContent() {
private val bytes by lazy(LazyThreadSafetyMode.NONE) {
text.toByteArrayPlatform(contentType.charset() ?: Charsets.UTF_8)
}
override val contentLength: Long
get() = bytes.size.toLong()
override fun bytes(): ByteArray = bytes
override fun toString(): String = "LargeTextContent[$contentType] \"${text.take(30)}\""
}
expect fun String.toByteArrayPlatform(charset: Charset): ByteArray
android (original version of toByteArray):
import kotlinx.io.charsets.Charset
import kotlinx.io.core.toByteArray
actual fun String.toByteArrayPlatform(charset: Charset): ByteArray {
return toByteArray(charset)
}
ios (fixed for my case):
import kotlinx.io.charsets.Charset
import kotlinx.serialization.toUtf8Bytes
actual fun String.toByteArrayPlatform(charset: Charset): ByteArray {
return toUtf8Bytes()
}
when i debugging i saw this stacktrace:
here used versions:
kotlin_version=1.3.30
coroutines_version=1.2.0
ktor_version=1.1.4
klock_version=1.4.0
serialization_version=0.11.0
and i get this bug at this versions too:
kotlin_version=1.3.21
coroutines_version=1.1.1
ktor_version=1.1.3
klock_version=1.2.2
serialization_version=0.10.0
The text was updated successfully, but these errors were encountered:
We're rebooting the kotlinx-io development (see #131), all issues related to the previous versions will be closed. Consider reopening it if the issue remains (or the feature is still missing) in a new version.
i use kotlinx-io not directly - just by ktor. My project is mobile app with shared library for ios & android, when i send very large textcontent by ktor (4mb photo from ios device encoded by base64) app stuck on call kotlinx.io.core.toByteArray and worked with 100% cpu usage by 30mins, and after it request is done and all complete. For fast fix i create my own TextContent, which use not kotlinx.io.core.toByteArray, but kotlinx.serialization.toUtf8Bytes on iOS platform. Here code:
android (original version of toByteArray):
ios (fixed for my case):
when i debugging i saw this stacktrace:

here used versions:
kotlin_version=1.3.30
coroutines_version=1.2.0
ktor_version=1.1.4
klock_version=1.4.0
serialization_version=0.11.0
and i get this bug at this versions too:
kotlin_version=1.3.21
coroutines_version=1.1.1
ktor_version=1.1.3
klock_version=1.2.2
serialization_version=0.10.0
The text was updated successfully, but these errors were encountered: