Prepare all the graphical assets in the DisplayLink thread, and asynchronously mark the view as need updating with:
DispatchQueue.main.async {
view.needsDisplay = true
}
Then do as little as possible and as much as necessary in draw to draw the contents.
Remarks
The context to which drawing commands are issued to is not static - it's instantiated on-demand.
NSView have the requirement that many of its interfaces be invoked only on the main thread.
Topic:
UI Frameworks
SubTopic:
AppKit
Tags: