https://kotlinlang.org logo
#ktor
Title
# ktor
t

Thomas

09/24/2020, 6:40 PM
In the latest Ktor version 1.4.1 I was able to freeze the Ktor client and still make network requests. That is really great, thanks a lot for making this possible. I was wondering if using the
Ios
engine from
Dispatchers.Default
is supported, too? I tried that and get an
IncorrectDereferenceException
from Ktor code. When I modify the Ktor
io.ktor.client.engine.ios.IosClientEngine
code (and related files in the same package) by adding some
freeze()
calls, it works fine when called from
Dispatchers.Default
. Is this expected behaviour at this time?
e

e5l

09/24/2020, 6:44 PM
Hey, thanks. We really going to improve iOS experience in future and adding
Dispatchers.Default
support is the next step
t

Thomas

09/24/2020, 7:08 PM
Hey, that is great news!
I added only two
freeze()
calls to the Ios engine code and it works with
Dispatchers.Default
in my project already.
Add_freezing_support_to_Ios_engine.patch
e

e5l

09/25/2020, 5:52 AM
That will prevent fall, but will not force to work in the dispatcher thread. That's also nice to fix, could you make a PR?
t

Thomas

09/25/2020, 8:24 AM
@e5l What exactly would you like me to create a PR for? Only adding the freeze calls like above or also fixing the dispatcher thread? I am not sure how to force it to work in the dispatcher thread.
e

e5l

09/25/2020, 8:25 AM
I'm about the first part of fix. I'm going to research the second part
t

Thomas

09/25/2020, 8:25 AM
I also noticed that instead of using freeze directly you use makeShared in Ktor. Which one of those would you like me to use in the PR?
e

e5l

09/25/2020, 8:26 AM
makeShared
is for common code, in native you can use
freeze
or
makeShared
t

Thomas

09/25/2020, 9:15 AM
The base branch is master, hope that is alright.
e

e5l

09/25/2020, 9:30 AM
Thanks, will take a look