2 Replies
      Latest reply on Sep 5, 2019 10:26 AM by Miro
      Miro Level 1 Level 1 (10 points)

        We are working on a MacOS app that was based on the face detection iOS sample code from Apple. We are experincing a frequent crash on Mac OS Mojave (version 10.14.6) but it is not happening on Catalina (beta 7) so far:


        Crashed Thread:        14  Dispatch queue: com.apple.root.default-qos
        Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
        Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000111013000
        Exception Note:        EXC_CORPSE_NOTIFY
        Termination Signal:    Segmentation fault: 11
        Termination Reason:    Namespace SIGNAL, Code 0xb
        Terminating Process:   exc handler [3453]


        Thread 14 Crashed:: Dispatch queue: com.apple.root.default-qos
        0   com.apple.vImage              0x00007fff28ab4f01 vConvert_ARGB8888To420Yp8_CbCr8_avx2 + 1489
        1   com.apple.vImage              0x00007fff28927aee Do_vImageConvert_ARGB8888To420Yp8_CbCr8 + 174
        2   libdispatch.dylib             0x00007fff58117672 _dispatch_client_callout2 + 8
        3   libdispatch.dylib             0x00007fff58126f95 _dispatch_apply_invoke + 157
        4   libdispatch.dylib             0x00007fff5811763d _dispatch_client_callout + 8
        5   libdispatch.dylib             0x00007fff58125509 _dispatch_root_queue_drain + 657
        6   libdispatch.dylib             0x00007fff58125b46 _dispatch_worker_thread2 + 90
        7   libsystem_pthread.dylib       0x00007fff583576b3 _pthread_wqthread + 583
        8   libsystem_pthread.dylib       0x00007fff583573fd start_wqthread + 13

        And another crash is happening in Core Animaiton after about 2 hours of running the app in both operating systems:


        Process:               Face Detector [12828]
        Path:                  /Users/USER/*/Face Detector.app/Contents/MacOS/Face Detector
        Identifier:            Face Detector
        Version:               0.6 (65)
        Code Type:             X86-64 (Native)
        Parent Process:        ??? [1]
        Responsible:           Face Detector [12828]
        User ID:               501
        Date/Time:             2019-09-03 11:34:05.305 -0700
        OS Version:            Mac OS X 10.15 (19A546d)
        Report Version:        12
        Bridge OS Version:     3.0 (14Y905)
        Anonymous UUID:        0C8321C5-745D-8A3A-1BF1-710CB74E8A04
        Time Awake Since Boot: 7200 seconds
        Thread 6 Crashed:: com.apple.coremedia.imagequeue.coreanimation.common
        0   libobjc.A.dylib               0x00007fff6f44914c realizeClassWithoutSwift(objc_class*, objc_class*) + 168
        1   libobjc.A.dylib               0x00007fff6f448fdc realizeClassMaybeSwiftMaybeRelock(objc_class*, mutex_tt&, bool) + 301
        2   libobjc.A.dylib               0x00007fff6f43ab1e lookUpImpOrForward + 715
        3   libobjc.A.dylib               0x00007fff6f43a3d9 _objc_msgSend_uncached + 73
        4   com.apple.CoreFoundation       0x00007fff39804163 __NSArrayM_new + 46
        5   com.apple.MediaToolbox         0x00007fff3e67d05c 0x7fff3e380000 + 3133532
        6   com.apple.CoreMedia           0x00007fff3a91db48 figThreadMain + 276
        7   libsystem_pthread.dylib       0x00007fff709aed76 _pthread_start + 125
        8   libsystem_pthread.dylib       0x00007fff709ab5d3 thread_start + 15

        The first crash is more critcal to resolve.  Is this crash indicating that there is an underlying problem in Vision framework in Mojave?  Or is there something do with how background queues are being used?


        Some additional context, the applicaiton is converting the video preview stream to images that get uploaded to Firebase when a face has been detected.  The CALayers for the tracking overlays are being composited into a new image with the video stream.   I don't think that is related to the crash.

        • Re: MacOS app using Vision framework is crashing
          Miro Level 1 Level 1 (10 points)

          I have made many code changes since the original post.  For some of the code where I compositing layers to make an NSImage then make JPEG to upload to Firebase, it was not on the main thread.  Thus, I changed those code blocks to be on the main thread.   I am seeing less crashing now.


          The core animation crash is still happening after half an hour or so of running the app. I am going to gather more crash logs.  Any advice greatly welcome.

            • Re: MacOS app using Vision framework is crashing
              Miro Level 1 Level 1 (10 points)

              With the help of another developer, one crash issue has been isolated.  But there is no fix as such as the crash is in the vision framework.


              The scenario is that the may be a lot of movment with more than one person & or one person moving very quickly towards the camera.


              guardlet observation = trackingResults[0] as? VNDetectedObjectObservation else {
                          let faceObservation = VNFaceObservation(boundingBox: observation.boundingBox)
                          faceLandmarksRequest.inputFaceObservations = [faceObservation]
                          // Continue to track detected facial landmarks.
                          let imageRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer,
                                                                          options: requestHandlerOptions)
                          do {
                             // CRASH happens here!
                              try imageRequestHandler.perform(faceLandmarkRequests)
                          } catch let error as NSError {
                              NSLog("Failed to perform FaceLandmarkRequest: %@", error)
                              self.faceDetected = false


              We are trying to think of ways to valiade the data before invokoing the handler.