<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">I’ve been investigating a problem with a long running application that accumulates an apparently unbounded number of<div>CVDisplayLink threads. I do not yet have an explanation or a test case.</div><div><br></div><div>The code that creates and releases CVDisplayLinks looks fine, but that assumes there are no threading issues.</div><div>It looks like there are threading issues.</div><div><br></div><div>Specifically, it appears that the startDisplayLink and stopDisplayLink methods of<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> the Objective-C class MTLLayer are invoked on multiple threads.</span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">They are invoked on the AppKit main thread from screen sleep notifications and blitTexture.</span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">They are invoked on the EDT from </span><font color="#000000"><span style="caret-color: rgb(0, 0, 0);">MTLLayer.validate.</span></font></div><div><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font></div><div><font color="#000000"><span style="caret-color: rgb(0, 0, 0);">They are invoked on the Queue Flusher thread from MTLRenderQueue.flushBuffer.</span></font></div><div><font color="#000000"><span style="caret-color: rgb(0, 0, 0);"><br></span></font></div><div>Perhaps someone familiar with this code could comment?</div><div><br></div></body></html>