Nested views wrapped in Link cause excessive CPU and memory usage
Originator: | nikhil | ||
Number: | rdar://FB13243190 | Date Originated: | 07/10/2023 |
Status: | Open | Resolved: | |
Product: | SwiftUI | Product Version: | iOS 17 RC Seed (21A329) |
Classification: | Bug | Reproducible: | Yes |
When multiple nested views are wrapped inside Link, it causes excessive CPU and memory usage. The attached sample code reproduces this issue. - Open the project - Run the `widgetsExtension` scheme from the project as-is (pre-configured to use the Release build config) - Observe spike in CPU and memory usage (this causes a excessive memory usage crash in production builds) - Stop the run cycle - Comment out all `Link` declarations, leaving the `Link.Label` as-is, so the content continues to render - Run the `widgetsExtension` scheme, and observe no spike in CPU or memory usage While the outermost `Link` should always take precedence (this behaviour is correctly observed), SwiftUI should then smartly skip evaluating inner `Link` declarations on only evaluate their labels, at-least for Widgets and complications. Built using Xcode Version 15.0 (15A240d) (also observed with XC 15.1 Beta 1) on macOS 14.0 (23A344) Sample Code at: https://github.com/dezinezync/FB13207951.git
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Edit
Sample code URL: https://github.com/dezinezync/FB13243190