CVDisplayLink fails to start from second thread.

Originator:matej.knopp
Number:rdar://FB13482573 Date Originated:12/21/2023
Status:Open Resolved:
Product:macOS Product Version:All
Classification:bug Reproducible:yes
 
Display link remembers the pthread_t from last display link thread but does not clean it in CVDisplayLinkStop. When next thread has identical pthread id display link will fail to start.

Code to reproduce:

#import <Foundation/Foundation.h>
#import <CoreVideo/CoreVideo.h>

int main(int argc, const char * argv[]) {
    CVDisplayLinkRef link;
    CVDisplayLinkCreateWithActiveCGDisplays(&link);
    CVDisplayLinkSetOutputHandler(link, ^(CVDisplayLinkRef displayLink, const CVTimeStamp* inNow, const CVTimeStamp* inOutputTime,
                                          CVOptionFlags flagsIn, CVOptionFlags* flagsOut) {
        return 0;
    });
    CVReturn res = CVDisplayLinkStart(link);
    assert(res == kCVReturnSuccess);
    CVDisplayLinkStop(link);
    [NSThread detachNewThreadWithBlock:^{
        CVReturn res = CVDisplayLinkStart(link);
        assert(res == kCVReturnSuccess);
    }];
    return 0;
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!