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 bug in ios 13,Main Thread Checker: UI API called on a background … #2651

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
14 changes: 10 additions & 4 deletions framework/Source/iOS/GPUImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ @interface GPUImageView ()
GLfloat backgroundColorRed, backgroundColorGreen, backgroundColorBlue, backgroundColorAlpha;

CGSize boundsSizeAtFrameBufferEpoch;

CGRect viewRect;
CALayer *viewLayer;
}

@property (assign, nonatomic) NSUInteger aspectRatio;
Expand Down Expand Up @@ -133,6 +136,9 @@ - (void)commonInit;
- (void)layoutSubviews {
[super layoutSubviews];

viewRect = self.bounds;
viewLayer = self.layer;

// The frame buffer needs to be trashed and re-created when the view size changes.
if (!CGSizeEqualToSize(self.bounds.size, boundsSizeAtFrameBufferEpoch) &&
!CGSizeEqualToSize(self.bounds.size, CGSizeZero)) {
Expand Down Expand Up @@ -165,7 +171,7 @@ - (void)createDisplayFramebuffer;
glGenRenderbuffers(1, &displayRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, displayRenderbuffer);

[[[GPUImageContext sharedImageProcessingContext] context] renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer];
[[[GPUImageContext sharedImageProcessingContext] context] renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)viewLayer];

GLint backingWidth, backingHeight;

Expand All @@ -187,7 +193,7 @@ - (void)createDisplayFramebuffer;

__unused GLuint framebufferCreationStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
NSAssert(framebufferCreationStatus == GL_FRAMEBUFFER_COMPLETE, @"Failure with display framebuffer generation for display of size: %f, %f", self.bounds.size.width, self.bounds.size.height);
boundsSizeAtFrameBufferEpoch = self.bounds.size;
boundsSizeAtFrameBufferEpoch = viewRect.size;

[self recalculateViewGeometry];
}
Expand Down Expand Up @@ -235,12 +241,12 @@ - (void)recalculateViewGeometry;
runSynchronouslyOnVideoProcessingQueue(^{
CGFloat heightScaling, widthScaling;

CGSize currentViewSize = self.bounds.size;
CGSize currentViewSize = viewRect.size;

// CGFloat imageAspectRatio = inputImageSize.width / inputImageSize.height;
// CGFloat viewAspectRatio = currentViewSize.width / currentViewSize.height;

CGRect insetRect = AVMakeRectWithAspectRatioInsideRect(inputImageSize, self.bounds);
CGRect insetRect = AVMakeRectWithAspectRatioInsideRect(inputImageSize, viewRect);

switch(_fillMode)
{
Expand Down