https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
i

Ivann Ruiz

09/08/2020, 5:20 PM
hi all 👋 currently using Kotlin/Ktor
1.4.0
to make a very simple API call on a multiplatform mobile project, however I get
Thread 1: EXC_BAD_ACCESS(code=1, ...)
error when I run the IOS code. Anybody run into this issue? It throws the error on this line in the
mainIos
source set:
actual val engine by lazy { Ios.create() }
would appreciate any insight 🙂
s

saket

09/08/2020, 6:13 PM
I think
lazy
will freeze implicitly, resulting in that crash because ktor doesn't support it yet
Have you tried using
atomicLazy
?
i

Ivann Ruiz

09/08/2020, 7:01 PM
Haven't tried
atomicLazy
but I had the same code with the
lazy{...}
on a project with Kotlin 1.3.72 and everything ran fine. Only getting this issue recently though 🤔
l

louiscad

09/09/2020, 6:16 AM
@Ivann Ruiz Which kotlinx.coroutines version do you see when you do
./gradlew :yourModule:dependencies
?
i

Ivann Ruiz

09/09/2020, 1:11 PM
I have coroutines version set to
1.3.9
. What fixed my freezing problem was to downgrade Ktor from
1.4.0
to
1.3.2-1.4.0-rc
m

Mike

09/15/2020, 9:41 PM
Hmm all I can say is be careful using ktor on iOS. Last time I ran into so many deadlock issues to even count, that I gave up after 2 weeks of debugging and trying to work around different issues. For example:
Copy code
<https://github.com/ktorio/ktor/issues/821>
<https://github.com/ktorio/ktor/issues/679>
<https://github.com/ktorio/ktor/issues/770>
nowadays I abstract the client to native ios/android implementations that make the network call using their own platform libraries