Forum Xamarin.Mac


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

AVCaptureSession Not Working?

roesterroester USUniversity ✭✭

I'm creating a Mac app with video capture. I've fairly comfortable with AVCaptureSession and have used it successfully on iOS without issue. When I move the code over to a Xam.Mac project, or try the sample AVCaptureSession code directly from the docs ( ), the capture session simply does not display on the Mac app window. Valid input (camera) and output (compressed video out) are added to the session, the preview layer created, sized, and assigned to the main view of the app, but nothing shows up in that main view. Also, no sample buffers are output to the AVCaptureVideoDataOutputSampleBufferDelegate.

I've already confirmed during debug sessions the input device is attached to the webcam, and other Mac OS video capture apps (not Xamarin based) are working fine with the same camera.

Is there a known issue using AVCaptureSession on Xam.Mac or should it work similarly to a Xam.iOS app?


  • roesterroester USUniversity ✭✭

    I forgot to mention I also added the video input user permission request to the info.plist so this isn't a permission issue.

    I can simplify the question...

    Has anyone successfully displayed a live camera preview from AVCaptureSession API in a Xamarin.Mac application?

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    That sounds like possibly a bug, or at least an annoying platform difference.

    Could you trim down your app to a tiny sample and file it at ?

  • roesterroester USUniversity ✭✭

    Thank you Chris for the reply. The most concise sample is the code in the MonoMac online documentation page for AVFoundation.AVCaptureSession class, located here:

    That "SetupCapture" code sample results in a session object that has the state "Running" but nothing shows up in the previewlayer, and no samples are output to the AVCaptureVideoDataOutputSampleBufferDelegate class.

    Will that do, or do you need me to package up the code on that documentation page and file it at GitHub?

    Thank you.

  • poupoupoupou CAMember, Xamarin Team Xamurai

    @roester the documentation sample code did not age well, it's both mentioning MonoMac. (classic era) and UIImage which is not available on macOS. I'll file internal issues on this (and you can leave feedback on the documentation site too).

    As for the issue please file an issue on GitHub and attach your (self contained) test case to it. That way we'll be sure we're looking at the same code/issue that you're experiencing (removing any guessing). Thanks!

  • roesterroester USUniversity ✭✭

    @poupou and @ChrisHamons I've created a new issue on GitHub with a simplified project as requested. I reduced all of the AVCaptureSession creation to a single method of the main ViewController class in the sample project attached to the issue.

    Issue: "AVCaptureSession not working on Xam.Mac #5390"

    I look forward to the review/feedback/solution.

    Thank you!

Sign In or Register to comment.