Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Xcode main thread warning #2533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
});
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked this by logging:

NSLog(@"Is main thread: %@", [NSThread isMainThread] ? @"YES" : @"NO");

Usually is "yes" but not always.


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