AVCaptureDevice.ExposureMode.locked not working on photo capture

I am using AVCaptureDevice.ExposureMode.locked and setWhiteBalanceModeLocked for capturing photos. On the live view/ camera view it is showing properly i.e exposure on face does not change with the background light. But when using capture image it shows blackish image in didFinishProcessing.

End goal is to capture image whose exposure or brightness does not change with the colour of clothes or background light.

Code used for reference: AVCamManual

Same, this behaviour is so weird, please help,

Using device.exposureMode = .locked, or device.exposureMode = .custom, or device.setExposureModeCustom() does not work. The live preview shows the updated ISO and exposureTime settings, and the printed values right before capturing confirm it.

But as soon as the code tries to .capturePhoto(), the settings are set back to auto, auto ISO, auto exposureTime, no honoring of the manual values set.

Only the exposure bias is honored, but if anything changes in the scene then the exposure will also change (because auto).

AVCaptureDevice.ExposureMode.locked not working on photo capture
 
 
Q