prevent freezing when opened 2 times via navigator (http://stackoverflow.com/questions/33046061/) (#380)
This commit is contained in:
parent
ae88ac7405
commit
f4bf30e17b
|
@ -34,7 +34,10 @@ RCT_EXPORT_MODULE();
|
|||
self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session];
|
||||
self.previewLayer.needsDisplayOnBoundsChange = YES;
|
||||
|
||||
return [[RCTCamera alloc] initWithManager:self bridge:self.bridge];
|
||||
if(!self.camera){
|
||||
self.camera = [[RCTCamera alloc] initWithManager:self bridge:self.bridge];
|
||||
}
|
||||
return self.camera;
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
|
@ -434,6 +437,7 @@ RCT_EXPORT_METHOD(hasFlash:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRej
|
|||
return;
|
||||
#endif
|
||||
dispatch_async(self.sessionQueue, ^{
|
||||
self.camera = nil;
|
||||
[self.previewLayer removeFromSuperlayer];
|
||||
[self.session commitConfiguration];
|
||||
[self.session stopRunning];
|
||||
|
|
Loading…
Reference in New Issue