Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIDITrackView could be implemented using SwiftUI canvas #47

Open
wtholliday opened this issue Feb 27, 2022 · 4 comments
Open

MIDITrackView could be implemented using SwiftUI canvas #47

wtholliday opened this issue Feb 27, 2022 · 4 comments
Assignees

Comments

@wtholliday
Copy link
Member

See https://developer.apple.com/documentation/swiftui/canvas

My machine beachballs for a few seconds when loading the cookbook example for MIDITrackView. After profiling, it seems this is due to it creating a CALayer for each note.

@emurray2
Copy link
Member

emurray2 commented Feb 27, 2022

See https://developer.apple.com/documentation/swiftui/canvas

My machine beachballs for a few seconds when loading the cookbook example for MIDITrackView. After profiling, it seems this is due to it creating a CALayer for each note.

Thanks for the feedback. I did notice that and was wondering why. I'll take a look at this soon and fix it when I can (school is busy now). But I also have an updated version of the code on my GitHub page as I mentioned. It doesn't include the canvas implementation, but feel free to adjust the code if you like.

@emurray2
Copy link
Member

emurray2 commented May 3, 2022

@wtholliday I saw the awesome piano roll you made. Is it still separate from what the midi track view does? If so, I can try to look at your code and match the style a bit to address this issue. I already did peek a bit, and now I understand what you mean by abstracting the model away from the view.

@emurray2
Copy link
Member

emurray2 commented Jan 3, 2023

See https://developer.apple.com/documentation/swiftui/canvas

My machine beachballs for a few seconds when loading the cookbook example for MIDITrackView. After profiling, it seems this is due to it creating a CALayer for each note.

@wtholliday Do you remember what tool you used to profile this?

@wtholliday
Copy link
Member Author

@emurray2 Time Profiler in Instruments

emurray2 added a commit to AudioKit/MIDITrackView that referenced this issue Dec 15, 2023
This commit fixes AudioKit/AudioKitUI#46 and AudioKit/AudioKitUI#47. Rewrote the MIDITrackView entirely in SwiftUI, used `drawingGroup()` to render one path layer for the notes to improve drawing efficiency and created MIDITrackViewModel to store note rectangles and track properties for drawing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants