Skip to content

Commit

Permalink
Fix crash in copypixelbuffer (flutter#10326)
Browse files Browse the repository at this point in the history
  • Loading branch information
WATER1350 authored and cbracken committed Oct 4, 2019
1 parent 86f54f2 commit 61f058d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion shell/platform/darwin/ios/ios_external_texture_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "flutter/flow/texture.h"
#include "flutter/fml/platform/darwin/cf_utils.h"
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterTexture.h"

namespace flutter {
Expand All @@ -33,7 +34,7 @@ class IOSExternalTextureGL : public flutter::Texture {
bool NeedUpdateTexture(bool freeze);

bool new_frame_ready_ = false;
NSObject<FlutterTexture>* external_texture_;
fml::scoped_nsobject<NSObject<FlutterTexture>> external_texture_;
fml::CFRef<CVOpenGLESTextureCacheRef> cache_ref_;
fml::CFRef<CVOpenGLESTextureRef> texture_ref_;
fml::CFRef<CVPixelBufferRef> buffer_ref_;
Expand Down
5 changes: 3 additions & 2 deletions shell/platform/darwin/ios/ios_external_texture_gl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

IOSExternalTextureGL::IOSExternalTextureGL(int64_t textureId,
NSObject<FlutterTexture>* externalTexture)
: Texture(textureId), external_texture_(externalTexture) {
: Texture(textureId),
external_texture_(fml::scoped_nsobject<NSObject<FlutterTexture>>([externalTexture retain])) {
FML_DCHECK(external_texture_);
}

Expand Down Expand Up @@ -65,7 +66,7 @@
GrContext* context) {
EnsureTextureCacheExists();
if (NeedUpdateTexture(freeze)) {
auto pixelBuffer = [external_texture_ copyPixelBuffer];
auto pixelBuffer = [external_texture_.get() copyPixelBuffer];
if (pixelBuffer) {
buffer_ref_.Reset(pixelBuffer);
}
Expand Down

0 comments on commit 61f058d

Please sign in to comment.