diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 2cc49edc2810795d6f7913043c8247ab3aca133f..1a7add32c37d0619c4f55490d3c734c0810065a6 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -1039,8 +1039,8 @@ napi_value ImageSourceNapi::CreatePixelMap(napi_env env, napi_callback_info info } ImageNapiUtils::HicheckerReport(); - IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreatePixelMap", CreatePixelMapExecute, - CreatePixelMapComplete, asyncContext, asyncContext->work); + IMG_CREATE_CREATE_ASYNC_WORK_WITH_QOS(env, status, "CreatePixelMap", CreatePixelMapExecute, + CreatePixelMapComplete, asyncContext, asyncContext->work, napi_qos_user_initiated); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to create async work")); @@ -1737,8 +1737,8 @@ napi_value ImageSourceNapi::CreatePixelMapList(napi_env env, napi_callback_info ImageNapiUtils::HicheckerReport(); napi_status status; - IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreatePixelMapList", CreatePixelMapListExec, - CreatePixelMapListComplete, asyncContext, asyncContext->work); + IMG_CREATE_CREATE_ASYNC_WORK_WITH_QOS(env, status, "CreatePixelMapList", CreatePixelMapListExec, + CreatePixelMapListComplete, asyncContext, asyncContext->work, napi_qos_user_initiated); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to create async work")); FinishTrace(HITRACE_TAG_ZIMAGE); diff --git a/frameworks/kits/js/common/include/image_napi_utils.h b/frameworks/kits/js/common/include/image_napi_utils.h index 3ae2e1391ce69247741fb9356db8e4c75402a6c3..26a96f2a5f6fe952469e18a27e3100f17928520e 100644 --- a/frameworks/kits/js/common/include/image_napi_utils.h +++ b/frameworks/kits/js/common/include/image_napi_utils.h @@ -69,6 +69,21 @@ do \ } \ } while (0) +#define IMG_CREATE_CREATE_ASYNC_WORK_WITH_QOS(env, status, workName, exec, complete, aContext, work, qos) \ +do \ +{ \ + napi_value _resource = nullptr; \ + napi_create_string_utf8((env), (workName), NAPI_AUTO_LENGTH, &_resource); \ + (status) = napi_create_async_work(env, nullptr, _resource, (exec), \ + (complete), static_cast((aContext).get()), &(work)); \ + if ((status) == napi_ok) { \ + (status) = napi_queue_async_work_with_qos((env), (work), (qos)); \ + if ((status) == napi_ok) { \ + (aContext).release(); \ + } \ + } \ +} while (0) + #define IMG_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) #define GET_BUFFER_BY_NAME(root, name, res, len) ImageNapiUtils::GetBufferByName(env, (root), (name), &(res), &(len))