"Heavy" view updates are ran on a background thread instead of the main thread #112
Replies: 2 comments 1 reply
-
I believe this is the expected behavior of That said, you probably want to explicitly apply |
Beta Was this translation helpful? Give feedback.
-
Thank you for the reply! Does this mean that, even when we dispatch to I'm still a little confused because I assume that dispatching to Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hello,
This isn't necessarily a
Perception
bug but more so a behavior I've noticed with both@Observable
and@Perceptible
. For this post, I will use@Observable
but the behavior is the same with@Perceptible
.I've noticed, if you make "light" / "simple" updates from a background thread using
@Observable
, it updates the view just fine.However, if the updates from the background thread are "heavy" (high volume of view updates triggered), I've noticed the view updates occur on the background thread.
I think I've so far only noticed this with UIViewRepresentable.
Does anyone have any insight into whats going on an why?
I know that you should probably ensure view updates are dispatched to the main actor by
await MainActor.run { /* update here */ }
, or by marking your view model / model with@MainActor
, but I'm more so trying to understand whats going on under the hood.Here is an example:
Thanks for your time!
Beta Was this translation helpful? Give feedback.
All reactions