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

kpgalligan

08/29/2019, 10:09 PM
Starting
freeze()
issue thread. Continued from here: https://kotlinlang.slack.com/archives/C3PQML5NU/p1567102026052800 cc @Kris Wong @basher
k

Kris Wong

08/29/2019, 10:10 PM
thanks
k

kpgalligan

08/29/2019, 10:10 PM
Thread is so we don’t sort out something interesting in private.
k

Kris Wong

08/29/2019, 10:18 PM
man, app code gets real confused when I right click in the editor
er, i don't even see how to run in tests in this thing
k

kpgalligan

08/29/2019, 10:23 PM
In app code?
k

Kris Wong

08/29/2019, 10:23 PM
yeah
k

kpgalligan

08/29/2019, 10:25 PM
I don’t know. I would just log before/after freeze and first confirm it is stopping there. The debugger may be tricky to set up for app code tests
k

Kris Wong

08/29/2019, 10:25 PM
that's definitely were it stopped when running in Xcode
let me try just running the app
k

kpgalligan

08/29/2019, 10:25 PM
How do you know if the debugger isn’t working?
k

Kris Wong

08/29/2019, 10:26 PM
i know it stopped there, I just can't step into the call to see where it stopped underneath that call
k

kpgalligan

08/29/2019, 10:27 PM
This is just freeze or it’s doing a bunch of threading stuff?
k

Kris Wong

08/29/2019, 10:27 PM
just freeze
k

kpgalligan

08/29/2019, 10:28 PM
You’re saying if I create an Xcode project and just call freeze on a kotlin object you’d expect it to deadlock?
In a test
k

Kris Wong

08/29/2019, 10:28 PM
well, the project is much complex than that, but that's essentially what happening
k

kpgalligan

08/29/2019, 10:29 PM
I guess I need to see that or I would assume something else is happening.
k

Kris Wong

08/29/2019, 10:30 PM
yeah I am trying to investigate but things are moving very slowly
k

kpgalligan

08/29/2019, 10:30 PM
I mean, I’ve had some strange issues with KN, but freeze deadlocking would indeed be a surprise
Freeze itself happens before you’ve shared code with other threads, so in theory it’s not locking on anything. If execution simply stops there, and you’re 100% sure it isn’t a crash or involved in some other form of infinite loop, it would be very interesting to see that in action.
k

Kris Wong

08/29/2019, 10:51 PM
wow, this is pretty spectacular
if you have this
actual fun <T> T.freeze(): T = this.freeze()
...
it's very important you also have this
import kotlin.native.concurrent.freeze
😂 2
b

basher

08/29/2019, 10:51 PM
ah nice
problem solved haha
k

Kris Wong

08/29/2019, 10:52 PM
because it builds w/o that, and then it's just an infinite loop
that was a fun exercise. thanks fellas.
k

kpgalligan

08/29/2019, 10:53 PM
I have done this
k

Kris Wong

08/29/2019, 10:55 PM
it's pretty easy to figure out when you can actually see the stack trace
a

Arkadii Ivanov

08/31/2019, 11:00 PM
You can use 'by' to import KN's freeze as e.g. 'freezeNative', then call it. It will be much less error prone.
🍻 1