mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
add the constructor of ILongFrame
Signed-off-by: dzf <duzifan@huawei.com>
This commit is contained in:
parent
3cad5e65d0
commit
e744c651b8
@ -234,6 +234,14 @@ if (!defined(global_parts_info) ||
|
||||
security_component_enable = false
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.resourceschedule_ffrt)) {
|
||||
ace_common_defines += [ "FFRT_EXISTS" ]
|
||||
resourceschedule_ffrt_support = true
|
||||
} else {
|
||||
resourceschedule_ffrt_support = false
|
||||
}
|
||||
|
||||
ace_platforms = []
|
||||
|
||||
_ace_adapter_dir = rebase_path("$ace_root/adapter", root_build_dir)
|
||||
|
@ -69,7 +69,6 @@ template("ace_osal_ohos_source_set") {
|
||||
"image_analyzer_mgr.cpp",
|
||||
"layout_inspector.cpp",
|
||||
"log_wrapper.cpp",
|
||||
"long_frame_report_impl.cpp",
|
||||
"modal_ui_extension_impl.cpp",
|
||||
"ressched_report.cpp",
|
||||
"socperf_client_impl.cpp",
|
||||
@ -81,7 +80,6 @@ template("ace_osal_ohos_source_set") {
|
||||
|
||||
external_deps += [
|
||||
"ability_runtime:app_manager",
|
||||
"ffrt:libffrt",
|
||||
"i18n:intl_util",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
@ -101,6 +99,12 @@ template("ace_osal_ohos_source_set") {
|
||||
defines += [ "SOC_PERF_ENABLE" ]
|
||||
}
|
||||
|
||||
if (defined(resourceschedule_ffrt_support) &&
|
||||
resourceschedule_ffrt_support) {
|
||||
sources += [ "long_frame_report_impl.cpp" ]
|
||||
external_deps += [ "ffrt:libffrt" ]
|
||||
}
|
||||
|
||||
external_deps += [
|
||||
"ability_base:view_data",
|
||||
"ability_base:want",
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "adapter/ohos/osal/long_frame_report_impl.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "base/longframe/long_frame_report.h"
|
||||
#include "base/ressched/ressched_report.h"
|
||||
|
||||
@ -22,35 +24,44 @@ namespace OHOS::Ace {
|
||||
namespace {
|
||||
constexpr int32_t LONG_FRAME_EVENT_DELAY = 10000;
|
||||
}
|
||||
LongFrameReportImpl::LongFrameReportImpl()
|
||||
{
|
||||
ffrtTaskQueue = std::make_unique<ffrt::queue>("long_frame_report_ffrt_queue",
|
||||
ffrt::queue_attr().qos(ffrt::qos_user_initiated));
|
||||
}
|
||||
|
||||
void LongFrameReportImpl::SubmitEvent()
|
||||
{
|
||||
ffrtTask = ffrtTaskQueue->submit_h([] {
|
||||
ffrtTask = ffrt::submit_h([] {
|
||||
ResSchedReport::GetInstance().ResSchedDataReport("long_frame_start");
|
||||
}, ffrt::task_attr().delay(LONG_FRAME_EVENT_DELAY));
|
||||
}, {}, {}, ffrt::task_attr().delay(LONG_FRAME_EVENT_DELAY));
|
||||
}
|
||||
|
||||
void LongFrameReportImpl::CancelEvent()
|
||||
{
|
||||
if (ffrtTaskQueue->cancel(ffrtTask)) {
|
||||
ffrtTaskQueue->wait(ffrtTask);
|
||||
if (ffrt::skip(ffrtTask)) {
|
||||
ffrt::wait({ffrtTask});
|
||||
ResSchedReport::GetInstance().ResSchedDataReport("long_frame_end");
|
||||
}
|
||||
}
|
||||
|
||||
ILongFrame::ILongFrame()
|
||||
{
|
||||
if (access(LIBFFRT_LIB64_PATH, F_OK) == -1) {
|
||||
return ;
|
||||
}
|
||||
is64BitSystem_ = true;
|
||||
}
|
||||
|
||||
void ILongFrame::ReportStartEvent()
|
||||
{
|
||||
if (!is64BitSystem_) {
|
||||
return ;
|
||||
}
|
||||
reporter = new LongFrameReportImpl();
|
||||
static_cast<LongFrameReportImpl*>(reporter)->SubmitEvent();
|
||||
}
|
||||
|
||||
void ILongFrame::ReportEndEvent()
|
||||
{
|
||||
if (!is64BitSystem_) {
|
||||
return ;
|
||||
}
|
||||
static_cast<LongFrameReportImpl*>(reporter)->CancelEvent();
|
||||
delete static_cast<LongFrameReportImpl*>(reporter);
|
||||
}
|
||||
|
@ -17,17 +17,17 @@
|
||||
#define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_LONG_FRAME_REPORT_IMPL_H
|
||||
|
||||
#include "base/longframe/long_frame_report.h"
|
||||
#include "ffrt.h"
|
||||
#include "ffrt_inner.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class LongFrameReportImpl {
|
||||
public:
|
||||
LongFrameReportImpl();
|
||||
LongFrameReportImpl() = default;
|
||||
~LongFrameReportImpl() = default;
|
||||
void SubmitEvent();
|
||||
void CancelEvent();
|
||||
|
||||
std::unique_ptr<ffrt::queue> ffrtTaskQueue = nullptr;
|
||||
private:
|
||||
ffrt::task_handle ffrtTask;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -73,7 +73,6 @@ ohos_source_set("preview_osal_source") {
|
||||
"file_uri_helper_preview.cpp",
|
||||
"frame_report.cpp",
|
||||
"image_source_preview.cpp",
|
||||
"long_frame_report_impl.cpp",
|
||||
"modal_ui_extension_impl.cpp",
|
||||
"mouse_style_ohos.cpp",
|
||||
"pixel_map_preview.cpp",
|
||||
@ -88,6 +87,11 @@ ohos_source_set("preview_osal_source") {
|
||||
"view_data_wrap_impl.cpp",
|
||||
]
|
||||
|
||||
if (defined(resourceschedule_ffrt_support) &&
|
||||
resourceschedule_ffrt_support) {
|
||||
sources += [ "long_frame_report_impl.cpp" ]
|
||||
}
|
||||
|
||||
cflags_cc = [
|
||||
"-DNAME_MAX=128",
|
||||
"-Wno-inconsistent-dllimport",
|
||||
|
@ -16,8 +16,13 @@
|
||||
#include "base/longframe/long_frame_report.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
ILongFrame::ILongFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void ILongFrame::ReportStartEvent()
|
||||
{
|
||||
reporter = nullptr;
|
||||
}
|
||||
|
||||
void ILongFrame::ReportEndEvent()
|
||||
|
@ -23,10 +23,12 @@ typedef void* EventReport;
|
||||
|
||||
class ACE_EXPORT ILongFrame final {
|
||||
public:
|
||||
ILongFrame() = default;
|
||||
ILongFrame();
|
||||
~ILongFrame() = default;
|
||||
void ReportStartEvent();
|
||||
void ReportEndEvent();
|
||||
|
||||
private:
|
||||
EventReport reporter = nullptr;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -27,7 +27,9 @@ constexpr uint32_t RES_TYPE_SLIDE = 11;
|
||||
constexpr uint32_t RES_TYPE_POP_PAGE = 28;
|
||||
constexpr uint32_t RES_TYPE_WEB_GESTURE = 29;
|
||||
constexpr uint32_t RES_TYPE_LOAD_PAGE = 34;
|
||||
#ifdef FFRT_EXISTS
|
||||
constexpr uint32_t RES_TYPE_LONG_FRAME = 71;
|
||||
#endif
|
||||
constexpr int32_t TOUCH_EVENT = 1;
|
||||
constexpr int32_t CLICK_EVENT = 2;
|
||||
constexpr int32_t SLIDE_OFF_EVENT = 0;
|
||||
@ -35,8 +37,10 @@ constexpr int32_t SLIDE_ON_EVENT = 1;
|
||||
constexpr int32_t PUSH_PAGE_START_EVENT = 0;
|
||||
constexpr int32_t PUSH_PAGE_COMPLETE_EVENT = 1;
|
||||
constexpr int32_t POP_PAGE_EVENT = 0;
|
||||
#ifdef FFRT_EXISTS
|
||||
constexpr int32_t LONG_FRAME_START_EVENT = 0;
|
||||
constexpr int32_t LONG_FRAME_END_EVENT = 1;
|
||||
#endif
|
||||
constexpr char NAME[] = "name";
|
||||
constexpr char PID[] = "pid";
|
||||
constexpr char UID[] = "uid";
|
||||
@ -50,8 +54,10 @@ constexpr char SLIDE_OFF[] = "slide_off";
|
||||
constexpr char TOUCH[] = "touch";
|
||||
constexpr char WEB_GESTURE[] = "web_gesture";
|
||||
constexpr char LOAD_PAGE[] = "load_page";
|
||||
#ifdef FFRT_EXISTS
|
||||
constexpr char LONG_FRAME_START[] = "long_frame_start";
|
||||
constexpr char LONG_FRAME_END[] = "long_frame_end";
|
||||
#endif
|
||||
|
||||
void LoadAceApplicationContext(std::unordered_map<std::string, std::string>& payload)
|
||||
{
|
||||
@ -107,6 +113,7 @@ void ResSchedReport::ResSchedDataReport(const char* name, const std::unordered_m
|
||||
reportDataFunc_(RES_TYPE_WEB_GESTURE, 0, payload);
|
||||
}
|
||||
},
|
||||
#ifdef FFRT_EXISTS
|
||||
{ LONG_FRAME_START,
|
||||
[this](std::unordered_map<std::string, std::string>& payload) {
|
||||
LoadAceApplicationContext(payload);
|
||||
@ -119,6 +126,7 @@ void ResSchedReport::ResSchedDataReport(const char* name, const std::unordered_m
|
||||
reportDataFunc_(RES_TYPE_LONG_FRAME, LONG_FRAME_END_EVENT, payload);
|
||||
}
|
||||
},
|
||||
#endif
|
||||
};
|
||||
auto it = functionMap.find(name);
|
||||
if (it == functionMap.end()) {
|
||||
|
@ -15,8 +15,12 @@
|
||||
|
||||
#include "core/pipeline_ng/ui_task_scheduler.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "base/log/frame_report.h"
|
||||
#ifdef FFRT_EXISTS
|
||||
#include "base/longframe/long_frame_report.h"
|
||||
#endif
|
||||
#include "base/memory/referenced.h"
|
||||
#include "base/utils/time_util.h"
|
||||
#include "base/utils/utils.h"
|
||||
@ -27,8 +31,19 @@
|
||||
#include "core/pipeline_ng/pipeline_context.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
namespace {
|
||||
const char* LIBFFRT_LIB64_PATH = "/system/lib64/ndk/libffrt.z.so";
|
||||
}
|
||||
uint64_t UITaskScheduler::frameId_ = 0;
|
||||
|
||||
UITaskScheduler::UITaskScheduler()
|
||||
{
|
||||
if (access(LIBFFRT_LIB64_PATH, F_OK) == -1) {
|
||||
return ;
|
||||
}
|
||||
is64BitSystem_ = true;
|
||||
}
|
||||
|
||||
UITaskScheduler::~UITaskScheduler()
|
||||
{
|
||||
persistAfterLayoutTasks_.clear();
|
||||
@ -90,9 +105,13 @@ void UITaskScheduler::FlushLayoutTask(bool forceUseMainThread)
|
||||
abort();
|
||||
}
|
||||
|
||||
#ifdef FFRT_EXISTS
|
||||
// Pause GC during long frame
|
||||
std::unique_ptr<ILongFrame> longFrame = std::make_unique<ILongFrame>();
|
||||
longFrame->ReportStartEvent();
|
||||
if (is64BitSystem_) {
|
||||
longFrame->ReportStartEvent();
|
||||
}
|
||||
#endif
|
||||
|
||||
isLayouting_ = true;
|
||||
auto dirtyLayoutNodes = std::move(dirtyLayoutNodes_);
|
||||
@ -114,7 +133,11 @@ void UITaskScheduler::FlushLayoutTask(bool forceUseMainThread)
|
||||
}
|
||||
ExpandSafeArea();
|
||||
|
||||
longFrame->ReportEndEvent();
|
||||
#ifdef FFRT_EXISTS
|
||||
if (is64BitSystem_) {
|
||||
longFrame->ReportEndEvent();
|
||||
}
|
||||
#endif
|
||||
|
||||
isLayouting_ = false;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ private:
|
||||
class ACE_EXPORT UITaskScheduler final {
|
||||
public:
|
||||
using PredictTask = std::function<void(int64_t, bool)>;
|
||||
UITaskScheduler() = default;
|
||||
UITaskScheduler();
|
||||
~UITaskScheduler();
|
||||
|
||||
// Called on Main Thread.
|
||||
@ -163,6 +163,7 @@ private:
|
||||
std::list<std::function<void()>> persistAfterLayoutTasks_;
|
||||
|
||||
uint32_t currentPageId_ = 0;
|
||||
bool is64BitSystem_ = false;
|
||||
bool isLayouting_ = false;
|
||||
|
||||
FrameInfo* frameInfo_ = nullptr;
|
||||
|
@ -16,8 +16,13 @@
|
||||
#include "base/longframe/long_frame_report.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
ILongFrame::ILongFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void ILongFrame::ReportStartEvent()
|
||||
{
|
||||
reporter = nullptr;
|
||||
}
|
||||
|
||||
void ILongFrame::ReportEndEvent()
|
||||
|
@ -49,7 +49,6 @@ ace_unittest("pipeline_context_test_ng") {
|
||||
"$ace_root/test/mock/base/mock_image_source.cpp",
|
||||
"$ace_root/test/mock/base/mock_jank_frame_report.cpp",
|
||||
"$ace_root/test/mock/base/mock_localization.cpp",
|
||||
"$ace_root/test/mock/base/mock_long_frame_report.cpp",
|
||||
"$ace_root/test/mock/base/mock_mouse_style.cpp",
|
||||
"$ace_root/test/mock/base/mock_pixel_map.cpp",
|
||||
"$ace_root/test/mock/base/mock_socperf_client_impl.cpp",
|
||||
@ -66,7 +65,6 @@ ace_unittest("pipeline_context_test_ng") {
|
||||
"$ace_root/test/mock/core/common/mock_image_analyzer_mgr.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_interaction.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_layout_inspector.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_raw_recognizer.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_theme_constants.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_udmf.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_window.cpp",
|
||||
@ -89,4 +87,8 @@ ace_unittest("pipeline_context_test_ng") {
|
||||
"$ace_root/test/unittest/core/pattern/text/mock/mock_text_layout_adapter.cpp",
|
||||
"pipeline_context_test_ng.cpp",
|
||||
]
|
||||
|
||||
if (defined(resourceschedule_ffrt_support) && resourceschedule_ffrt_support) {
|
||||
sources += [ "$ace_root/test/mock/base/mock_long_frame_report.cpp" ]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user