Andrew Watson
11/23/2024, 12:25 AM_dispatch_workloop_worker_thread
(s); does that mean virtually all the app's functionality is working on the main thread?Andrew Watson
11/23/2024, 12:54 AMkotlinx.atomicfu
locks:Andrew Watson
11/23/2024, 12:54 AMAndrei Salavei
11/23/2024, 8:47 AMSynchronizedObject
is used inside Compose Snapshot system - and it can cause performance drops if you're updating your app state too frequently.Andrew Watson
11/23/2024, 7:49 PMURLSessionWebSocketTask,
and I guess I don't know which thread it's on. But it doesn't appear to be on the worker threads on iOS.
• What's the way to minimize SynchronizedObject
utilizations? Just use compose best practices/minimize recomps?
Thanks for any assistance; this app has a lot of functionality and could be a great KMP/CMP case study, so I really wanna get it right!Andrei Salavei
11/25/2024, 8:34 AMShould this operate as it does in Android on iOS? Or behind the scenes is it just running everything on main thread?Coroutines on iOS and Android work pretty much the same. So there is no implicit dispatches in the main queue.
What is the proper way to offload network operations to the IO/worker threads in KMP iOS? I'm using aTheand I guess I don't know which thread it's on. But it doesn't appear to be on the worker threads on iOS.URLSessionWebSocketTask,
URLSessionWebSocketTask
dispatches result callback on background (e.g. working) queue. FYI you can check NSURLSession
documentation, as well as iOS dispatching model (which calls GCD).
What's the way to minimizeSure, best practices will help you here.utilizations? Just use compose best practices/minimize recomps?SynchronizedObject
Andrei Salavei
11/25/2024, 8:49 AMNikita Lipsky
11/25/2024, 1:48 PMWhat's the way to minimizeWhat Compose version do you use? We don't useutilizations?SynchronizedObject
atomicfu SynchronizedObject
implementation in Compose Runtime starting from Compose 1.7.0Andrew Watson
11/25/2024, 6:00 PMAndrew Watson
11/26/2024, 11:36 PMAndrew Watson
11/26/2024, 11:40 PMkotlinx.atomicfu.SynchronizedObject
running for most of those 8 seconds. The child trace of that object looks like a garbage collection operation. The kicker here is that I've upgraded compose to 1.7.5, plugin to 1.7.0. So a couple questions:
• Is this likely a memory leak/running out of memory-based hang?
• Why is SynchronizedObject
still being used in Compose 1.7 code? Note: I am using kotlin compiler 1.9.23
Any thoughts you have on this would be super helpful!Andrew Watson
11/27/2024, 12:38 AMAndrei Salavei
11/27/2024, 7:48 AMNikita Lipsky
11/27/2024, 11:12 AMSynchronizedObject.lock
. Now it is nor clear what actually eats those 8s.
> Why is SynchronizedObject
still being used in Compose 1.7 code?
Could you show the stack trace above SynchronizedObject.lock
, who actually calls it?
> Note: I am using kotlin compiler 1.9.23
Please try Kotlin 2.0.21: there are many GC performance improvements in it. If the problem still persists with it, please create a reproducer and file an issue in Kotlin issue tracker.Andrew Watson
11/27/2024, 6:22 PMAndrew Watson
11/27/2024, 6:26 PMVsevolod Tolstopyatov [JB]
11/28/2024, 10:16 AMVsevolod Tolstopyatov [JB]
11/28/2024, 10:19 AMNikita Lipsky
11/28/2024, 10:28 AMSynchronizedObject
still being used in Compose 1.7 code?
From the trace, we see that the usages of SynchronizedObject
are from iOS coroutines implementation not from Compose Runtime.
As you see above, we have created an issue on this but if you could provide a reproducer as well it would facilitate investigations.Andrew Watson
11/30/2024, 12:26 AMAndrew Watson
11/30/2024, 12:27 AMAndrew Watson
11/30/2024, 12:27 AMNikita Lipsky
12/02/2024, 10:12 AMAndrew Watson
12/02/2024, 6:48 PMkotlinx-coroutines-core
1.9.0Andrew Watson
12/02/2024, 6:52 PMAndrew Watson
12/09/2024, 8:28 PMkotlinx.atomicfu.locsk.SychronizedObject
utilizations as before, but not in the UI as you noted; it's lower level operatios
• One thing I was wondering; my app is making heaving use of SharedFlow
; our app is based on websockets, and the library I inherited utilizes shared flows to emit update events and the like. I notice in the tracing what calls SynchronizedObject
ends up being SharedFlowImpl.tryTakeValue
; should I attempt to rework my code to minimize SharedFlow usage?Andrew Watson
12/09/2024, 8:38 PM