Skip to content

Commit

Permalink
Update SGVideoRenderer.m
Browse files Browse the repository at this point in the history
Fix video replacing crash in background
  • Loading branch information
chaocharleswang committed Sep 8, 2019
1 parent 72d35ab commit 3e07a07
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion SGPlayer/Classes/Core/SGRenderer/SGVideoRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,13 @@ - (void)drawInMTKView:(MTKView *)view
}
MTLViewport viewports[2] = {};
NSArray<SGMetalProjection *> *projections = nil;
id<CAMetalDrawable> drawable = [(CAMetalLayer *)self->_metalView.layer nextDrawable];
CAMetalLayer *layer = (CAMetalLayer *)self->_metalView.layer;

if (layer.drawableSize.width == 0 || layer.drawableSize.height == 0) {
return;
}

id<CAMetalDrawable> drawable = [layer nextDrawable];
MTLSize textureSize = MTLSizeMake(width, height, 0);
MTLSize layerSize = MTLSizeMake(drawable.texture.width, drawable.texture.height, 0);
switch (displayMode) {
Expand Down

0 comments on commit 3e07a07

Please sign in to comment.