Alan iOS Concurrency - Understanding Dispatch Queues and Operation Queues
Concurrency Programming - Covers all the concepts of synchronization and asynchrony required in iOS programming, as well as GCD and Operation that extend it.
Why update UI on main thread?
Hello. It's been a while since I've brought you some news.
It's nothing else,
There is a good article on the question Why should you update your UI on the main thread?, so I created a translation and would like to share it with you.
I hope this will be of some help to you.
(Original source of the article)
https://medium.com/@duwei199714/ios-why-the-ui-need-to-be-updated-on-main-thread-fd0fef070e7f
(Interpretation PDF file)
https://drive.google.com/file/d/1dFw6sJsxV-huK3BoHXgDq-7rXy9yBq9l/view?usp=sharing
To summarize briefly,
1) All properties of UIKit cannot be designed to be thread-safe because it can cause performance degradation such as slowdown . (It is Apple's intention to design it not to be thread-safe.)
2) The main runloop is designed to update the view simultaneously through the View Drawing Cycle , which manages the update of the view. However, when a background thread (not the main thread) performs such operation with its own runloop, the view may behave arbitrarily. (For example, For example, when you rotate the device, you may not be able to do the same thing where the view's layout is rearranged.)
3) iOS has a rendering process for drawing images (CoreAnimation -> RenderServer -> GPU -> Display) , and if changes in each view are sent to the GPU from multiple threads, the GPU has to interpret each piece of information, which can slow down or be inefficient.
4) Although there are asynchronous UI frameworks developed by Facebook called Texture and ComponentKit, they ensure that the View Drawing Cycle is updated simultaneously on the main thread at the appropriate timing in a similar manner.
About this much This is the content. In fact, this was an article that made me think again about whether, for similar reasons as mentioned above, not only iOS but also Windows and other OSes , UI updates are structurally limited to the main thread .
It's just a topic you might think about once in a while.. I hope it helps a little bit ^^
thank you .


