You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bug is fully reproducible. Leaving the App open for some more minutes even leads to a crash. I'll have a quick look into the crash to gather more information.
View uses 13% CPU on my blue iPhone even when no sound is playing. Partly to AURemoteIO and partly on main thread.
View uses roughly 50% CPU when sound is playing: Partly in SwiftUI.AsyncRenderer
When sound is playing: Memory footprint constantly increasest at a rate of 100KB per second
CPU usage constantly increases, to 100% in a about a minute. On main thread
Memory Graph:
There's a UICollectionView List with about 1200 Mutable Dictionaries. These dictionaries contain some runtime information (see below)
There are more than 3000 CFStrings lingering around, showing a orange icond with a drop. The contain all the same value eyJEQkd [...] Ijp0cnVlfQ==
The Mutable Dictionaires are inited by the CFPrefs and by a CGPath (moveto, quadto, lineto, ...)
View Hierarchy with clipped content shows a grotesque amount of ZStacks (see attached screenshot)
Xcode shows an Optimization Opportunity: "The layer is using dynamic shadows which are expensive to render. If possible try setting shadowPath, or pre-rendering the shadow into an image and putting it under the layer."
Pausing and continuing the app with Debugger: Memory clears, CPU usage dropts to 40% and starts increasing again.
It looks like a memory leak or some silly code that creates elements in a tight loop and garbage collector / reference counter can't act quick enough to free the memory again.
Starting the app with attached debugger will not lead to a crash, even after running for more than an hour (on CPU 100%).
Next step: Look into the code to understand where all these dicts come from.
No Strings and dicts are explicitely created. Could it be due to some debugging stuff? will a release build also have the same problems?
Fresh FFT results might come too quick
.animation of AmplitudeBar and Cap View might interfere with fresh FFT data: the animation is running until the end even when fresh data is already shown
.drawingGroup (Metal rendering) is on HStack, it might be better on each bar (because of List View)
GeometryReader in a thight loop (ForEach fresh amplitude reading), this is discouraged by Apple. The width and height could be read once (on appear and on change of orientation / layout) and the passed to the other views in @Environment or as a member
@mahal appreciate your insight on this! To me it seems SwiftUI rendering is messing something up, as you showed the huge amount of views rendered one on top of another... I bet that's the key area to look in.
In the mean time I just replace the rendering with Charts (iOS 16+) and it works perfect
Activity
mahal commentedon Aug 3, 2024
The bug is fully reproducible. Leaving the App open for some more minutes even leads to a crash. I'll have a quick look into the crash to gather more information.
mahal commentedon Aug 3, 2024
Findings without looking at the code:
eyJEQkd [...] Ijp0cnVlfQ==shadowPath, or pre-rendering the shadow into an image and putting it under the layer."It looks like a memory leak or some silly code that creates elements in a tight loop and garbage collector / reference counter can't act quick enough to free the memory again.
Starting the app with attached debugger will not lead to a crash, even after running for more than an hour (on CPU 100%).
Next step: Look into the code to understand where all these dicts come from.
mahal commentedon Aug 3, 2024
Code analysis:
alexdmotoc commentedon Aug 3, 2024
@mahal appreciate your insight on this! To me it seems SwiftUI rendering is messing something up, as you showed the huge amount of views rendered one on top of another... I bet that's the key area to look in.
In the mean time I just replace the rendering with Charts (iOS 16+) and it works perfect