Fix crash in copypixelbuffer (flutter/engine#10326)

This commit is contained in:
WATER1350 2019-10-05 04:21:17 +08:00 committed by Chris Bracken
parent 46149914bb
commit bf73ca111d
2 changed files with 5 additions and 3 deletions

View File

@ -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 {
@ -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_;

View File

@ -16,7 +16,8 @@ namespace flutter {
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_);
}
@ -65,7 +66,7 @@ void IOSExternalTextureGL::Paint(SkCanvas& canvas,
GrContext* context) {
EnsureTextureCacheExists();
if (NeedUpdateTexture(freeze)) {
auto pixelBuffer = [external_texture_ copyPixelBuffer];
auto pixelBuffer = [external_texture_.get() copyPixelBuffer];
if (pixelBuffer) {
buffer_ref_.Reset(pixelBuffer);
}