diff --git a/frameworks/surfaceimage/src/native_image.cpp b/frameworks/surfaceimage/src/native_image.cpp index 5eecad7de2..38e8755bef 100644 --- a/frameworks/surfaceimage/src/native_image.cpp +++ b/frameworks/surfaceimage/src/native_image.cpp @@ -130,13 +130,12 @@ int32_t OH_NativeImage_GetSurfaceId(OH_NativeImage* image, uint64_t* surfaceId) BLOGE("parameter error"); return SURFACE_ERROR_INVALID_PARAM; } + *surfaceId = image->consumer->GetUniqueId(); if (image->pSurface == nullptr) { image->pSurface = Surface::CreateSurfaceAsProducer(image->producer); } BLOGE_CHECK_AND_RETURN_RET(image->pSurface != nullptr, SURFACE_ERROR_UNKOWN, "pSurface is null"); - - *surfaceId = image->consumer->GetUniqueId(); return SURFACE_ERROR_OK; }