SimpleCam
SimpleCam copied to clipboard
camera setup is really slow on very first start on device
On the very first start on a device it takes maybe 20 sec or more to start up simplecam. On the second start it opens immediately. I tried with the demo supplied. If I delete the app and restart it again, it is fast.
Does anybody have an idea?
Hi @plenio I'm not sure when I'll get a chance to profile this, have you by chance run instruments to see if you can isolate what's causing the lag?
Hi @LoganWright I have now found a way to reproduce it easily. Just open the SimpleCam sample and change the bundle identifier. If you open it on iphone4s it takes about 15 secs to open camera.
The app seems to wait for a very long time doing nothing, even in the profiler. There is only a single function that takes very long cpu time(888 ms) which is the call tree capturePhoto(line 568)-crop-drawInRect(line 822).
This is all I can say. Does that give you a clue?
Regards, Werner
I could reproduce in debug environment and get an exception now.
It crashes in line 216 - [self.view addSubview:_imageStreamV];
Here is the log:
This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x20dcc123
OK, I have a fix for this.
In viewDidAppear change the code following this code:
case AVAuthorizationStatusNotDetermined: {
// not determined
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if(granted){
with this
if(granted){
dispatch_async(dispatch_get_main_queue(), ^{
[self setup];
[self animateIntoView];
});
This should do for ios8+. Maybe there is something else necessary for ios < 8 Hope this is of help to someone
@plenio Would you be willing to submit a PR for this fix? I'm fine w/ also bumping minimum support to 8.0.
Thanks again for bringing this up!