I am trying to run a display link in a thread other than main but it simply doesn't work. I have a simple dispatch queue created like queue = DispatchQueue(label: "xyz") and then I create the display link as usual:
queue.async {
self.displayLink = CADisplayLink(target: self, selector: #selector(render))
self.displayLink.add(to: .current, forMode: .common)
}
The selector never gets called. Upon checking the currentMode of the RunLoop I see it is nil. What am I missing?
Thanks
Due to the reason that your queue is non-main, the current run loop won't trigger by itself.
You should call
current.run()manually after displayLink been added.