Has anyone seen issues with Reaktive after upgradi...
# reaktive
m
Has anyone seen issues with Reaktive after upgrading from Kotlin 1.7 to 1.8/1.9 where sometimes an iOS app freezes after restarting from the background in low mem scenarios? After commenting out a bunch of network calls that uses reaktive, the issue went away, and now I'm trying to narrow it down to the problematic call. This only repros on 1.8/1.9 and not 100% repro. It wasn't a problem on 1.7. I think there is some kind of deadlock occurring. The app becomes unresponsive until I background it, and then the OS kills it after 10 seconds (and a crash .ipa file is generated with no stacktrace, though it does mention a bunch of rx calls pending)
a
Interesting! Never heard about any such issues.
m
Not sure if it is a SwiftUI issue or Rx/Reaktive/Network issue. When the app starts up, some network calls are made via KMP code while SwiftUI renders, and commenting out the network calls fixed things. Anyways it's just a matter of uncommenting things one by one to figure out what's causing it now
a
Yeah, let me know! Also do you use the new memory model?
m
Yeah I'm using the new Kotlin memory model for a while now
I skipped kotlin 1.8 due to not being able to track down the cause of the issue, but it happens on 1.9 too
a
Which Reaktive version you are using?
m
This works: Kotlin 1.7.21, Reaktive 1.2.3 This has the issue mentioned above: Kotlin 1.9.0, Reaktive 1.3.0 (Similarly for Kotlin 1.8.x)
a
Thanks! Once you figure out the actual code causing the issue, please also try Reaktive 2.0.0-alpha01
👍 1
m
I wasn’t able to track down the cause but after migrating to coroutines + mvikotlin the issue is gone
a
Sad that we don't know the actual cause. There could be a bug, or maybe it was just due to incorrect usage.
m
Yeah it was hard to track down, too many things happening in the app, many background workers starting up. Also not a 100% repro, seems to sometimes happen when resuming the app but I can’t repro it consistently.
Also many dependencies got updated from kotlin 1.7 to 1.9
a
Was that the primary reason why you switched to coroutines?
m
Nope I had been wanting to switch to coroutines, the ecosystem is much better now for multiplatform than a few years ago. For example I use KMP-NativeCoroutines on iOS to convert to RxSwift, which got rid of a lot of boiler plate code around wrappers.
👍 1
Just to follow up, the issue repro’d again using coroutines on the latest version of kotlin, but very rarely (like 1/20th as many reports). So the issue is not due to reaktive but some other issue. I still need to track it down.
a
Thank you for the update. Please keep me updated if possible, because I'm curious. And let me know if you need any help.
👍 1
m
I noticed SQLDelight also underwent changes in their 2.0 native driver and there's some deadlocks due to changed behavior: https://github.com/cashapp/sqldelight/issues/4478 - I'm looking more into that. Going to downgrade SQLDelight to pre-2.0 and see if issue goes away.
👀 1
Just to follow up... the issue was due to deadlocks when running some work off the main thread. I don't know why upgrading kotlin to 1.8 exposes the issue, but to work around the issue I moved all kotlin native background work onto the same background thread. I am still investigating what is causing the deadlock.
a
Yeah, I also thought about dead locks. Thanks for the updates! Let me know if you need any help.
👍 1