The application I'm working on works on both the iPhone and iPad. One of the functionality of the application is to capture images from the camera. I am using UIImagePickerController for this function. Here is my code block,
self.imagePicker.sourceType = .camera self.imagePicker.cameraCaptureMode = .photo self.present(self.imagePicker, animated: true, completion: nil)
The application works the way it was developed on the iPhone, when ever I run the same code on the iPad, the application freezes. This problem occurs only on the iPad, but only on the rear camera. If I select the front camera from the image picker, the application starts the camera, but it freezes when I press the camera switch button.
As far as I understand from the magazine, the problem occurs when the application tries to draw a camera.
Logs:
2016-12-20 20:10:33.708816 Ronin[681:148977] CGContextAddPath: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. Dec 20 20:10:33 Ronin[681] <Error>: CGContextAddPath: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 2016-12-20 20:10:33.708925 Ronin[681:148977] clip: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. Dec 20 20:10:33 Ronin[681] <Error>: clip: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 2016-12-20 20:10:33.708991 Ronin[681:148977] CGContextSetFillColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. Dec 20 20:10:33 Ronin[681] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 2016-12-20 20:10:33.709047 Ronin[681:148977] CGContextFillRects: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. Dec 20 20:10:33 Ronin[681] <Error>: CGContextFillRects: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
iPad I use for testing: iPad Air 2 - iOS 10.2
EDIT
The UIImagePickerController.isSourceTypeAvailable (.camera) code returns true for my test case. I have already added this control, but have not mentioned it before.
I also noticed that when the application is frozen, the memory consumption starts to increase, and in one place the application crashed due to using too much memory.
In addition, I created an empty project and implemented the same approach for capturing an image that worked the way it was created in an empty project. At the moment, I think this problem may be related to some project settings.
EDIT - 2
I added a symbolic breakpoint for CGPostError, here is stacktrace:
It appears that the reason for the failure is the invalid context sent to the UIProgressView.
Any help would be appreciated.
EDIT - 3
As I mentioned earlier, I check the UIImagePickerController.isSourceTypeAvailable (.camera) in my code block, the problem is not related to camera accessibility. Also, the camera works like a popover when I present it modally.