ios - AVCaptureSession App Crash stopRunning -


i've got fake camera app. practically user thinks camera real , it's not. in view call live camera so:

    - (void)viewdidappear:(bool)animated {     [super viewdidappear:animated];      nsstring *path = [nsstring stringwithformat:@"%@/photoshutter.mp3",                       [[nsbundle mainbundle] resourcepath]];     nsurl *soundurl = [nsurl fileurlwithpath:path];      _player = [[avaudioplayer alloc] initwithcontentsofurl:soundurl                                                      error:nil];       //----- show live camera preview -----     avcapturesession *session = [[avcapturesession alloc] init];     session.sessionpreset = avcapturesessionpresetlow;      calayer *viewlayer = self.vimagepreview.layer;     nslog(@"viewlayer = %@", viewlayer);      avcapturevideopreviewlayer *capturevideopreviewlayer = [[avcapturevideopreviewlayer alloc] initwithsession:session];      capturevideopreviewlayer.frame = self.vimagepreview.bounds;     [self.vimagepreview.layer addsublayer:capturevideopreviewlayer];      avcapturedevice *device = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo];      avcapturedeviceinput *input = [avcapturedeviceinput deviceinputwithdevice:device error:nil];     if (!input) {         // handle error appropriately.         nslog(@"error: trying open camera");     }     [session addinput:input];      [session startrunning]; } 

this works expected. on next view, have button returns main menu. once user returns menu call:

    - (void)viewdidload {     [super viewdidload];      avcapturesession *session = [[avcapturesession alloc] init];     [session stoprunning];     avcapturedevice *device = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo];     session=nil;     device=nil; } 

this works fine. during debugging today, crashed app after 28 30 views of fake camera. ran device tethered xcode , lost connection device error. memory stable @ 17mb through out use, , cpu has high of 15%. no memory errors, thing in read-out few nslayoutconstraint breaks main menu. if @ rep notice new developer. appreciate help. thank you!

note: app doesn't take photos.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -