Skip to content

Commit ae1ed97

Browse files
committed
Grabs a snapshot of values from the main thread
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
1 parent 167b038 commit ae1ed97

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

framework/Source/iOS/GPUImageView.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,19 @@ - (void)presentFramebuffer;
232232

233233
- (void)recalculateViewGeometry;
234234
{
235+
__block CGRect currentBounds;
236+
237+
runOnMainQueueWithoutDeadlocking(^{
238+
currentBounds = self.bounds;
239+
});
240+
235241
runSynchronouslyOnVideoProcessingQueue(^{
236242
CGFloat heightScaling, widthScaling;
237-
238-
CGSize currentViewSize = self.bounds.size;
239-
243+
240244
// CGFloat imageAspectRatio = inputImageSize.width / inputImageSize.height;
241245
// CGFloat viewAspectRatio = currentViewSize.width / currentViewSize.height;
242-
243-
CGRect insetRect = AVMakeRectWithAspectRatioInsideRect(inputImageSize, self.bounds);
246+
247+
CGRect insetRect = AVMakeRectWithAspectRatioInsideRect(inputImageSize, currentBounds);
244248

245249
switch(_fillMode)
246250
{
@@ -251,14 +255,14 @@ - (void)recalculateViewGeometry;
251255
}; break;
252256
case kGPUImageFillModePreserveAspectRatio:
253257
{
254-
widthScaling = insetRect.size.width / currentViewSize.width;
255-
heightScaling = insetRect.size.height / currentViewSize.height;
258+
widthScaling = insetRect.size.width / currentBounds.size.width;
259+
heightScaling = insetRect.size.height / currentBounds.size.height;
256260
}; break;
257261
case kGPUImageFillModePreserveAspectRatioAndFill:
258262
{
259-
// CGFloat widthHolder = insetRect.size.width / currentViewSize.width;
260-
widthScaling = currentViewSize.height / insetRect.size.height;
261-
heightScaling = currentViewSize.width / insetRect.size.width;
263+
// CGFloat widthHolder = insetRect.size.width / currentBounds.size.width;
264+
widthScaling = currentBounds.size.height / insetRect.size.height;
265+
heightScaling = currentBounds.size.width / insetRect.size.width;
262266
}; break;
263267
}
264268

0 commit comments

Comments
 (0)