Post

Replies

Boosts

Views

Activity

CGDisplayStream API hangs on MacOS15 for same name process
Hi, recently some users of my app upgrade MacOS to 15, and encounter hang when trying to get screen capture permission. After looking into this issue, I find out a repoducible way. If two processes of a same program both call CGDisplayStreamCreate/CGDisplayImageCreate API, the later one will hang(No need to be at almost same time). Here are my demo codes. #import <AVFoundation/AVFoundation.h> #import <CoreGraphics/CoreGraphics.h> #import <Foundation/Foundation.h> int main(int argc, const char *argv[]) { @autoreleasepool { CGDirectDisplayID displayID = CGMainDisplayID(); CGDisplayStreamRef stream = CGDisplayStreamCreate( displayID, 1, 1, kCVPixelFormatType_32BGRA, nil, ^(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef){ }); if (!stream) { NSLog(@"Failed to create display stream!"); return 1; } else { NSLog(@"Create display stream success!"); CFRelease(stream); } } sleep(10); return 0; } The call of sleep is just to ensure I can run a second process of this program before the first one ends. It turns out that the first process checks the permission correctly and sleeps successfully. However the second process won't be able to print anything because it hangs when calling CGDisplayStreamCreate. Here is the output of sample: Call graph: 2546 Thread_1315735 DispatchQueue_1: com.apple.main-thread (serial) + 2546 start (in dyld) + 2840 [0x196f8f274] + 2546 main (in testapp) + 76 [0x100ef7e38] + 2546 SLDisplayStreamCreate (in SkyLight) + 316 [0x19d38163c] + 2546 SLSDisplayStreamCreateProxying (in ScreenCaptureKit) + 816 [0x231e2d614] + 2546 _dispatch_semaphore_wait_slow (in libdispatch.dylib) + 76 [0x19715e278] + 2546 _dispatch_sema4_timedwait (in libdispatch.dylib) + 64 [0x19715dc78] + 2546 semaphore_timedwait_trap (in libsystem_kernel.dylib) + 8 [0x1972ceda8] 2546 Thread_1315737 2546 start_wqthread (in libsystem_pthread.dylib) + 8 [0x19730b0f0] 2546 _pthread_wqthread (in libsystem_pthread.dylib) + 364 [0x19730c424] 2546 __workq_kernreturn (in libsystem_kernel.dylib) + 8 [0x1972d0a64] If I copy the program and run two different programs, the second program won't hang. This issue doesn't happen on MacOS early version. Can anybody help?
1
1
455
Jul ’24
App crashed for mach_vm_map assertion failed
Translated Report (Full Report Below) Version: 1.0.0 (2.0) Code Type: X86-64 (Translated) Parent Process: launchd [1] User ID: 948009654 Date/Time: 2023-11-02 19:47:33.1522 +0800 OS Version: macOS 12.1 (21C52) Report Version: 12 Anonymous UUID: 815896E6-939E-002C-08C6-C903A4B87DF4 Sleep/Wake UUID: F06CECA0-3643-4423-A6F4-1163217FF863 Time Awake Since Boot: 100000 seconds Time Since Wake: 92675 seconds System Integrity Protection: enabled Crashed Thread: 0 CrBrowserMain Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Application Specific Information: Assertion failed: (mach_vm_map(mach_task_self(), &address, size, 0, VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_COREGRAPHICS_BACKINGSTORES), port, 0, false, prot, prot, VM_INHERIT_SHARE) == KERN_SUCCESS), function backing_map, file CGSBackingStore.c, line 192. Kernel Triage: VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get VM - Compressor failed a blocking pager_get Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread 0 <translation info unavailable> 0x108107a20 ??? 1 libsystem_kernel.dylib 0x7ff8023cd5e2 __sigreturn + 10 2 ??? 0x7fc103a4f190 ??? 3 libsystem_c.dylib 0x7ff80234dd10 abort + 123 4 libsystem_c.dylib 0x7ff80234d0be __assert_rtn + 314 5 SkyLight 0x7ff8075129de backing_map + 550 6 SkyLight 0x7ff8072c82ad lock_window_backing + 557 7 SkyLight 0x7ff807369f41 SLSDeviceLock + 54 8 CoreGraphics 0x7ff8076e6550 ripd_Lock + 56 9 CoreGraphics 0x7ff807678772 RIPLayerBltShape + 490 10 CoreGraphics 0x7ff8076769c7 ripc_Render + 328 11 CoreGraphics 0x7ff8076737d4 ripc_DrawRects + 482 12 CoreGraphics 0x7ff807673565 CGContextFillRects + 145 13 CoreGraphics 0x7ff8076734c4 CGContextFillRect + 117 14 CoreGraphics 0x7ff807672fe8 CGContextClearRect + 52 15 HIToolbox 0x7ff80b6176e0 HIMenuBarView::DrawOnce(CGRect, CGRect, bool, HIMenuBarTextAppearance, CGContext*) + 110 16 HIToolbox 0x7ff80b617640 HIMenuBarView::DrawIntoWindow(unsigned int*, CGRect, double, CGRect, bool, HIMenuBarTextAppearance, CGContext*) + 410 17 HIToolbox 0x7ff80b53c146 HIMenuBarView::DrawSelf(short, __HIShape const*, CGContext*) + 280 18 HIToolbox 0x7ff80b53bd56 HIMenuBarView::DrawingDelegateHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 262 19 HIToolbox 0x7ff80b520d1d DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1391 20 HIToolbox 0x7ff80b52014e SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 333 21 HIToolbox 0x7ff80b51ffef SendEventToEventTargetWithOptions + 45 22 HIToolbox 0x7ff80b53b8d3 HIView::SendDraw(short, OpaqueGrafPtr*, __HIShape const*, CGContext*) + 325 23 HIToolbox 0x7ff80b53b399 HIView::RecursiveDrawComposited(__HIShape const*, __HIShape const*, unsigned int, HIView*, CGContext*, unsigned char, double) + 571 24 HIToolbox 0x7ff80b53b56d HIView::RecursiveDrawComposited(__HIShape const*, __HIShape const*, unsigned int, HIView*, CGContext*, unsigned char, double) + 1039 25 HIToolbox 0x7ff80b53add8 HIView::DrawComposited(short, OpaqueGrafPtr*, __HIShape const*, unsigned int, HIView*, CGContext*) + 832 26 HIToolbox 0x7ff80b53aa89 HIView::Render(unsigned int, CGContext*) + 51 27 HIToolbox 0x7ff80b5521a9 FlushWindowObject(WindowData*, void**, unsigned char) + 772 28 HIToolbox 0x7ff80b551c2f FlushAllBuffers(__CFRunLoopObserver*, unsigned long, void*) + 317 29 CoreFoundation 0x7ff8024c6f98 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 30 CoreFoundation 0x7ff8024c6e34 __CFRunLoopDoObservers + 543 31 CoreFoundation 0x7ff8024c5830 CFRunLoopRunSpecific + 446 32 HIToolbox 0x7ff80b5474f1 RunCurrentEventLoopInMode + 292 33 HIToolbox 0x7ff80b547118 ReceiveNextEventCommon + 284 34 HIToolbox 0x7ff80b546fe5 _BlockUntilNextEventMatchingListInModeWithFilter + 70 35 AppKit 0x7ff804e1bb4c _DPSNextEvent + 886 36 AppKit 0x7ff804e1a1b8 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1411 37 AppKit 0x7ff804e0c5a9 -[NSApplication run] + 586 38 libqcocoa.dylib 0x11402762f QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2495 39 QtCore 0x11ace2acf QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431 40 QtCore 0x11ace7042 QCoreApplication::exec() + 130 Anyone knows why it happens and how to fix it?
0
0
512
Nov ’23