jordibruin / Swift-Charts-Examples

An overview of the different types of charts you can make with Swift Charts
MIT License
1.95k stars 126 forks source link

Is anyone else noticing the app lagging? #44

Closed theedov closed 2 years ago

theedov commented 2 years ago

Is it just Xcode being Xcode, or the sample app is becoming laggy with all those charts? Testing on a simulator since I don't have iOS16 Beta installed.

https://user-images.githubusercontent.com/30866972/173708500-f03c7daa-c64f-4808-8160-f5380cf70053.mov

atrinh0 commented 2 years ago

Seeing the same.

CPU Spikes to 100% when scrolling.

Screenshot 2022-06-15 at 11 25 18
jordibruin commented 2 years ago

I wonder if there’s a way we can optimize the charts on the overview page. I have not tested it on device.

Otherwise a toggle to switch between images of the graphs and actual graphs might be a solution?

atrinh0 commented 2 years ago

Issue appears to be the List deallocating cells and redrawing the charts when the user scrolls back into view.

Setting the List to a ScrollView where every chart is loaded and not released when scrolled out of view gives us a smoother experience.

I am wondering if there is a way to keep the List however remove the cell reuse.

https://user-images.githubusercontent.com/16542463/173820017-e0c925f6-f88e-4564-ba2d-43dcbea1732a.mp4

jordibruin commented 2 years ago

I looked into rendering an image of the graph with the imageRenderer on first launch and then putting that image instead of the graph. It works okay but I have not found an elegant solution, and it seems the scale is a bit off. Any other suggestions?

We can always just take the screenshots that are in the README and add them to the project instead 🤔

atrinh0 commented 2 years ago

Potential solution perhaps, https://github.com/jordibruin/Swift-Charts-Examples/pull/52

Thoughts?

jordibruin commented 2 years ago

Good one for now! Thanks!