Skip to content

Commit

Permalink
Grabs a snapshot of values from the main thread
Browse files Browse the repository at this point in the history
Otherwise, reading any UIKit values like `.bounds` will give a warning:
Main Thread Checker: UI API called on a background thread: -[UIView bounds]

Taking out debug code
  • Loading branch information
lacyrhoades committed Nov 25, 2017
1 parent 167b038 commit ae1ed97
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions framework/Source/iOS/GPUImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,19 @@ - (void)presentFramebuffer;

- (void)recalculateViewGeometry;
{
__block CGRect currentBounds;

runOnMainQueueWithoutDeadlocking(^{
currentBounds = self.bounds;
});

runSynchronouslyOnVideoProcessingQueue(^{
CGFloat heightScaling, widthScaling;

CGSize currentViewSize = self.bounds.size;


// CGFloat imageAspectRatio = inputImageSize.width / inputImageSize.height;
// CGFloat viewAspectRatio = currentViewSize.width / currentViewSize.height;
CGRect insetRect = AVMakeRectWithAspectRatioInsideRect(inputImageSize, self.bounds);

CGRect insetRect = AVMakeRectWithAspectRatioInsideRect(inputImageSize, currentBounds);

switch(_fillMode)
{
Expand All @@ -251,14 +255,14 @@ - (void)recalculateViewGeometry;
}; break;
case kGPUImageFillModePreserveAspectRatio:
{
widthScaling = insetRect.size.width / currentViewSize.width;
heightScaling = insetRect.size.height / currentViewSize.height;
widthScaling = insetRect.size.width / currentBounds.size.width;
heightScaling = insetRect.size.height / currentBounds.size.height;
}; break;
case kGPUImageFillModePreserveAspectRatioAndFill:
{
// CGFloat widthHolder = insetRect.size.width / currentViewSize.width;
widthScaling = currentViewSize.height / insetRect.size.height;
heightScaling = currentViewSize.width / insetRect.size.width;
// CGFloat widthHolder = insetRect.size.width / currentBounds.size.width;
widthScaling = currentBounds.size.height / insetRect.size.height;
heightScaling = currentBounds.size.width / insetRect.size.width;
}; break;
}

Expand Down

0 comments on commit ae1ed97

Please sign in to comment.