"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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
This isn't necessarily a
Perceptionbug but more so a behavior I've noticed with both@Observableand@Perceptible. For this post, I will use@Observablebut 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