diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index a113f3763bb336f89d7bc9b2ea808a949cd13915..199a20cbc6acd16dc494e195d9fe82cbd9e68a22 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -160,6 +160,10 @@ void OHOSExternalTextureGL::Attach() } OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; + if (ohosSurfaceGLSkia_->GetOnscreenSurface() == nullptr) { + FML_LOG(WARNING) << "onscreen_surface_ is null, Attach failed"; + return; + } auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); if (result->GetResult()) { FML_DLOG(INFO) << "ResourceContextMakeCurrent successed"; diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 6e7b35e11e7f2529f91eead062736c2347bebe8f..92c7edda716a0d43c1ade785783d810f267de0fa 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -100,7 +100,7 @@ class OHOSExternalTextureGL : public flutter::Texture { void ProducePixelMapToBackGroundImage(); - enum class AttachmentState { uninitialized, attached, detached, }; + enum class AttachmentState { uninitialized, attached, detached }; AttachmentState state_;