https://kotlinlang.org logo
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
benchmarks
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
confetti
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
lincheck
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by
Title
j

John O'Reilly

08/18/2020, 8:57 PM
Using Ktor on client for Kotlin Multiplatform project and getting exception with 1.4 set of libraries when running on iOS with
native-mt
kotlinx coroutines (and also updated to
CIO
engine as it seems is now required to use this). Following is set of dependencies I'm using (also updated in following branch - https://github.com/joreilly/BikeShare/tree/1.4). (exception in thread....)
const val kotlin = "1.4.0"
    const val kotlinxCoroutines = "1.3.9-native-mt"
    const val ktor = "1.4.0"
    const val kotlinxSerialization = "1.0.0-RC"
HttpClient: REQUEST: <http://api.citybik.es/v2/networks/galway>
HttpClient: METHOD: HttpMethod(value=GET)
HttpClient: COMMON HEADERS
HttpClient: -> Accept: application/json
HttpClient: -> Accept-Charset: UTF-8
HttpClient: CONTENT HEADERS
HttpClient: BODY Content-Type: null
HttpClient: BODY START
HttpClient: 
HttpClient: BODY END
HttpClient: RESPONSE: 200 OK
HttpClient: METHOD: HttpMethod(value=GET)
HttpClient: FROM: <http://api.citybik.es/v2/networks/galway>
HttpClient: COMMON HEADERS
HttpClient: -> Access-Control-Allow-Origin: *
HttpClient: -> Content-Length: 5198
HttpClient: -> Content-Type: application/json
HttpClient: -> Date: Tue, 18 Aug 2020 20:50:16 GMT
HttpClient: -> Server: nginx/1.15.9 (Ubuntu)
HttpClient: -> Vary: Accept-Encoding
HttpClient: -> Via: kong/1.2.1
HttpClient: -> X-Kong-Proxy-Latency: 1
HttpClient: -> X-Kong-Upstream-Latency: 58
HttpClient: -> X-RateLimit-Limit-minute: 180
HttpClient: -> X-RateLimit-Remaining-minute: 179
HttpClient: BODY Content-Type: application/json
HttpClient: BODY START
Uncaught Kotlin exception: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[MainDispatcher, Continuation @ $split$lambda-0$<anonymous>_3COROUTINE$2]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
    at 0   BikeShare                           0x000000010497915c kfun:kotlin.Error#<init>(kotlin.String?;kotlin.Throwable?){} + 124
    at 1   BikeShare                           0x0000000104af113c kfun:kotlinx.coroutines.CoroutinesInternalError#<init>(kotlin.String;kotlin.Throwable){} + 124
    at 2   BikeShare                           0x0000000104b3f3e9 kfun:kotlinx.coroutines.DispatchedTask#handleFatalException(kotlin.Throwable?;kotlin.Throwable?){} + 953
    at 3   BikeShare                           0x0000000104b3efc7 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 3543
    at 4   BikeShare                           0x0000000104b76278 kfun:kotlinx.coroutines.DarwinMainDispatcher.dispatch$lambda-0#internal + 88
    at 5   BikeShare                           0x0000000104b7664e kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$41.invoke#internal + 62
    at 6   BikeShare                           0x0000000104b766ae kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$41.$<bridge-UNN>invoke(){}#internal + 62
    at 7   BikeShare                           0x0000000104b77767 _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f7265_knbridge8 + 183
    at 8   libdispatch.dylib                   0x000000010584cf11 _dispatch_call_block_and_release + 12
    at 9   libdispatch.dylib                   0x000000010584de8e _dispatch_client_callout + 8
    at 10  libdispatch.dylib                   0x000000010585bd97 _dispatch_main_queue_callback_4CF + 1149
    at 11  CoreFoundation                      0x00007fff23da1869 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    at 12  CoreFoundation                      0x00007fff23d9c3b9 __CFRunLoopRun + 2041
    at 13  CoreFoundation                      0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
    at 14  GraphicsServices                    0x00007fff38c39bbe GSEventRunModal + 139
    at 15  UIKitCore                           0x00007fff49325968 UIApplicationMain + 1605
    at 16  BikeShare                           0x00000001048e371b main + 75 (/Users/joreilly/dev/github/BikeShare/ios/BikeShare/BikeShare/AppDelegate.swift:13:7)
    at 17  libdyld.dylib                       0x00007fff520ce1fd start + 1
    at 18  ???                                 0x0000000000000001 0x0 + 1
Caused by: kotlinx.coroutines.CompletionHandlerException: Exception in completion handler ChildCompletion[ChildHandle[DeferredCoroutine{Cancelled}@fa55c8], kotlin.Unit] for DeferredCoroutine{Cancelled}@fa55c8
    at 0   BikeShare                           0x000000010497931c kfun:kotlin.Exception#<init>(kotlin.String?;kotlin.Throwable?){} + 124
    at 1   BikeShare                           0x000000010497956c kfun:kotlin.RuntimeException#<init>(kotlin.String?;kotlin.Throwable?){} + 124
    at 2   BikeShare                           0x0000000104af109c kfun:kotlinx.coroutines.CompletionHandlerException#<init>(kotlin.String;kotlin.Throwable){} + 124
    at 3   BikeShare                           0x0000000104af6e06 kfun:kotlinx.coroutines.JobSupport.notifyCompletion#internal + 1606
    at 4   BikeShare                           0x0000000104af5a38 kfun:kotlinx.coroutines.JobSupport.completeStateFinalization#internal + 1464
    at 5   BikeShare                           0x0000000104af3bc9 kfun:kotlinx.coroutines.JobSupport.finalizeFinishingState#internal + 1705
    at 6   BikeShare                           0x0000000104b00ad4 kfun:kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath#internal + 2036
    at 7   BikeShare                           0x0000000104b001b0 kfun:kotlinx.coroutines.JobSupport.tryMakeCompleting#internal + 736
    at 8   BikeShare                           0x0000000104affbd2 kfun:kotlinx.coroutines.JobSupport#makeCompletingOnce(kotlin.Any?){}kotlin.Any? + 642
    at 9   BikeShare                           0x0000000104ad42e6 kfun:kotlinx.coroutines.AbstractCoroutine#resumeWith(kotlin.Result<1:0>){} + 310
    at 10  BikeShare                           0x00000001049a214a kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 1450
    at 11  BikeShare                           0x0000000104b3eaa8 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2232
    at 12  BikeShare                           0x0000000104b76278 kfun:kotlinx.coroutines.DarwinMainDispatcher.dispatch$lambda-0#internal + 88
    ... and 14 more common stack frames skipped
Caused by: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlinx.coroutines.AwaitAll.AwaitAllNode@224ce68
    at 0   BikeShare                           0x000000010498052d kfun:kotlin.Throwable#<init>(kotlin.String?){} + 93
    at 1   BikeShare                           0x000000010497926b kfun:kotlin.Exception#<init>(kotlin.String?){} + 91
    at 2   BikeShare                           0x00000001049794bb kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 91
    at 3   BikeShare                           0x00000001049af10b kfun:kotlin.native.concurrent.InvalidMutabilityException#<init>(kotlin.String){} + 91
    at 4   BikeShare                           0x00000001049b09c2 ThrowInvalidMutabilityException + 690
    at 5   BikeShare                           0x0000000104aaa43c MutationCheck + 108
    at 6   BikeShare                           0x0000000104ad6936 kfun:kotlinx.coroutines.AwaitAll.AwaitAllNode.<set-handle>#internal + 102
    at 7   BikeShare                           0x0000000104ad5b08 kfun:kotlinx.coroutines.AwaitAll.await#internal + 1240
    at 8   BikeShare                           0x0000000104ad5071 kfun:kotlinx.coroutines.$awaitAllCOROUTINE$1#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any? + 1425
    at 9   BikeShare                           0x0000000104ad5344 kfun:kotlinx.coroutines#awaitAll@kotlin.collections.Collection<kotlinx.coroutines.Deferred<0:0>>(){0§<kotlin.Any?>}kotlin.collections.List<0:0> + 244
    at 10  BikeShare                           0x0000000104c5f3b6 kfun:io.ktor.util.$split$lambda-0COROUTINE$3.invokeSuspend#internal + 2358
    at 11  BikeShare                           0x00000001049a1e96 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 758
    at 12  BikeShare                           0x0000000104b3ece2 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2802
    at 13  BikeShare                           0x0000000104b76278 kfun:kotlinx.coroutines.DarwinMainDispatcher.dispatch$lambda-0#internal + 88
    ... and 14 more common stack frames skipped
(lldb)
e

e5l

08/19/2020, 4:05 AM
@Vsevolod Tolstopyatov [JB]
j

John O'Reilly

08/20/2020, 11:13 AM
Is there any examples of Ktor 1.4 working with
native-mt
kotlinx coroutines on iOS or macOS ....have tried a few different things but still getting crashes?
one other thing I noticed is that Ktor 1.4 seems to have dependency on
1.3.8-native-mt-1.4.0-rc1.3.8-native-mt-1.4.0-rc
(which is then "mapped" to
1.3.9-native-mt
)...maybe clutching at straws but just in case that's an issue
+--- io.ktor:ktor-client-core:1.4.0
|    \--- io.ktor:ktor-client-core-jvm:1.4.0
|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.0 (*)
|         +--- org.slf4j:slf4j-api:1.7.30
|         +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.4.0
|         +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8-native-mt-1.4.0-rc -> 1.3.9-native-mt (*)
🙌 1
t

tylerwilson

08/20/2020, 10:02 PM
I also had a crash on iOS when using coroutines 1.3.9. When I switched to 1.3.8-native-mt-1.4.0-rc everything started working fine. I did not switch to CIO, leaving it to the default engine (NSURLSession on iOS I am pretty sure). That is interesting how you traced through the versions. That is part of what messed me up was the naming of the version for coroutines.
w

william

08/24/2020, 11:51 AM
do you guys have any more info about fixing this?
j

John O'Reilly

08/24/2020, 11:52 AM
@russhwolf seems to have isolated this to issue with ktor logging.....if I disable that then seems to work fine (along with use of CIO on iOS at least for me)
e

e5l

08/24/2020, 11:53 AM
Could you file an YT issue about that?
r

russhwolf

08/24/2020, 11:53 AM
e

e5l

08/24/2020, 11:54 AM
Awesome, thanks
r

russhwolf

08/24/2020, 11:54 AM
I was able to get the default iOS engine working by disabling logging in that sample. Haven't tried CIO yet
j

John O'Reilly

08/24/2020, 11:54 AM
my changes using setup I mentioned are in following now https://github.com/joreilly/BikeShare
ktor/native-mt now seems to be happily working on both iOS and macOS (again, with logging disabled)