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?

Answered by Asteroid in 715433022

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

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.

Accepted Answer

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!

Activating Portrait Effect in AVFoundation
 
 
Q