Activating Portrait Effect in AVFoundation

I have an AVFoundation-based live camera view. There is a button by which I am calling AVCaptureDevice.showSystemUserInterface(.videoEffects) so that the user can activate the Portrait Effect. I have also opted in by setting "Camera — Opt in for Portrait Effect" to true in info.plist. However, upon tapping on the button I see this screen (The red crossed-off part is the app name):

I am expecting to see something like this:

Do you have any idea why that might be?

Accepted Reply

Finally I figured that by restarting the phone the problem goes away! As weird as it sounds :)

Replies

As mentioned in the comments of this thread: https://developer.apple.com/forums/thread/706199?answerId=713913022#713913022

Not every capture format supports the Portrait effect, you should iterate through the supported formats array of your AVCaptureDevice, and choose a format (set it as the activeFormat) that reports true for the isPortraitEffectSupported property.

  • So it's showing me that freaky view because the activeFormat doesn't support the Portrait Effect? Doesn't it sound like a bug?

  • Hello, please try in iOS 15.5. If you still see the same issue, please file a bug report using Feedback Assistant.

  • I tried in in several devices. It turns out the weird view happens on iPhone (tried iPhone 13 Pro Max, 11, 8 and SE 2nd gen), but it look just fine on iPad. (all running iOS 15.5)

Add a Comment

Finally I figured that by restarting the phone the problem goes away! As weird as it sounds :)

Interesting, well please do still file a bug report if you haven’t already!