fix(ios): ensure orientation is retrieved from main thread (#1958)

This commit is contained in:
justinkiang 2018-12-13 01:44:07 -08:00 committed by Laurin Quast
parent 5d27349115
commit cf0e96417d
2 changed files with 10 additions and 2 deletions

View File

@ -99,7 +99,11 @@
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CIImage *ciImage = [CIImage imageWithCVPixelBuffer:imageBuffer];
// set correct orientation
UIInterfaceOrientation curOrientation = [[UIApplication sharedApplication] statusBarOrientation];
__block UIInterfaceOrientation orientation;
dispatch_sync(dispatch_get_main_queue(), ^{
orientation = [[UIApplication sharedApplication] statusBarOrientation];
});
UIInterfaceOrientation curOrientation = orientation;
if (curOrientation == UIInterfaceOrientationLandscapeLeft){
ciImage = [ciImage imageByApplyingOrientation:3];

View File

@ -83,7 +83,11 @@
if(acceleration.y >= 0.75) {
return UIInterfaceOrientationPortraitUpsideDown;
}
return [[UIApplication sharedApplication] statusBarOrientation];
__block UIInterfaceOrientation orientation;
dispatch_sync(dispatch_get_main_queue(), ^{
orientation = [[UIApplication sharedApplication] statusBarOrientation];
});
return orientation;
}
- (AVCaptureVideoOrientation)convertToAVCaptureVideoOrientation:(UIInterfaceOrientation)orientation