SwiftUI macOS performance issue when frequently updating content in the UI

Hi,

I'm building a SwiftUI MacOS app that requires text in a section of the UI to be frequently updated, as the content changes every 0.2-0.5 seconds.

The attached sample code represents portion of my UI with elements positioned as they will be, but it's quite CPU intensive and is marked as High Energy Impact, consuming about 13%, and I don't know how to make it better. An acceptable range would be up to 3% and a rating of Low Energy Impact.

I tried adding .id("identifier") to portions of the UI in order to prevent redraw but it did not help. I also tried adding .drawingGroup() to portions of the UI in order to render them in Metal but it also did not improve performance. Lastly, I modified the ForEach() wrapper to use a List and it reduced the CPU utilization by half, but it's not something I want to use as I don't like having both vertical and horizontal scrollbars without being able to remove them.

Thanks in advance for your help. I'm running Xcode 12 Beta 6 on macOS Catalina 10.15.6.



SwiftUI macOS performance issue when frequently updating content in the UI
 
 
Q