mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-02-19 23:40:59 +00:00
add performance sysevent
Signed-off-by: xiahaiqin <xiahaiqin1@huawei.com> Change-Id: I25d90164ec9777d497b76f75e4aa4bb11c68d84d
This commit is contained in:
parent
9c47a89b6b
commit
4a2c097af0
@ -40,7 +40,7 @@
|
||||
domain: WINDOWMANAGER
|
||||
|
||||
NO_FOCUS_WINDOW:
|
||||
__BASE: {type: FAULT, level: CRITICAL, desc: The event is not consumed }
|
||||
__BASE: {type: FAULT, level: CRITICAL, desc: The event is not consumed}
|
||||
PID: {type: INT32, desc: session pid}
|
||||
UID: {type: INT32, desc: session uid}
|
||||
PACKAGE_NAME: {type: STRING, desc: package name}
|
||||
@ -48,11 +48,19 @@ NO_FOCUS_WINDOW:
|
||||
MSG: {type: STRING, desc: windowmanager event message}
|
||||
|
||||
WINDOW_LIFE_CYCLE_EXCEPTION:
|
||||
__BASE: {type: FAULT, level: CRITICAL, desc: The window life cycle is abnormal }
|
||||
__BASE: {type: FAULT, level: CRITICAL, desc: The window life cycle is abnormal}
|
||||
PID: {type: INT32, desc: session pid}
|
||||
UID: {type: INT32, desc: session uid}
|
||||
MSG: {type: STRING, desc: windowmanager event message}
|
||||
|
||||
WINDOW_BOOT_ANIMATION_DONE:
|
||||
__BASE: {type: BEHAVIOR, level: CRITICAL, desc: Boot animation done }
|
||||
MSG: {type: STRING, desc: windowmanager event message}
|
||||
__BASE: {type: BEHAVIOR, level: CRITICAL, desc: Boot animation done}
|
||||
MSG: {type: STRING, desc: windowmanager event message}
|
||||
|
||||
SHOW_WINDOW_TIME:
|
||||
__BASE: {type: STATISTIC, level: MINOR, desc: Sow window time performance}
|
||||
MSG: {type: STRING, desc: windowmanager event message}
|
||||
|
||||
GET_SNAPSHOT_TIME:
|
||||
__BASE: {type: STATISTIC, level: MINOR, desc: Get snapshot time performance}
|
||||
MSG: {type: STRING, desc: windowmanager event message}
|
||||
|
@ -80,6 +80,23 @@ enum class PropertyChangeAction : uint32_t {
|
||||
ACTION_UPDATE_PRIVACY_MODE = 1 << 15,
|
||||
};
|
||||
|
||||
struct ShowWindowTimeConfig {
|
||||
std::atomic<uint32_t> showWindowTimes_;
|
||||
std::atomic<uint32_t> below20msTimes_;
|
||||
std::atomic<uint32_t> below35msTimes_;
|
||||
std::atomic<uint32_t> below50msTimes_;
|
||||
std::atomic<uint32_t> above50msTimes_;
|
||||
};
|
||||
|
||||
struct GetSnapshotTimeConfig {
|
||||
std::atomic<uint32_t> getSnapshotTimes_;
|
||||
std::atomic<uint32_t> below25msTimes_;
|
||||
std::atomic<uint32_t> below35msTimes_;
|
||||
std::atomic<uint32_t> below50msTimes_;
|
||||
std::atomic<uint32_t> below200msTimes_;
|
||||
std::atomic<uint32_t> above200msTimes_;
|
||||
};
|
||||
|
||||
struct ModeChangeHotZonesConfig {
|
||||
bool isModeChangeHotZoneConfigured_;
|
||||
uint32_t fullscreenRange_;
|
||||
|
@ -549,12 +549,12 @@ ColorSpace WindowImpl::GetColorSpace()
|
||||
|
||||
std::shared_ptr<Media::PixelMap> WindowImpl::Snapshot()
|
||||
{
|
||||
WLOGFI("WMS-Clinet Snapshot");
|
||||
WLOGFI("WMS-Client Snapshot");
|
||||
std::shared_ptr<SurfaceCaptureFuture> callback = std::make_shared<SurfaceCaptureFuture>();
|
||||
RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode_, callback);
|
||||
std::shared_ptr<Media::PixelMap> pixelMap = callback->GetResult(2000); // wait for <= 2000ms
|
||||
if (pixelMap != nullptr) {
|
||||
WLOGFI("WMS-Clinet Save WxH = %{public}dx%{public}d", pixelMap->GetWidth(), pixelMap->GetHeight());
|
||||
WLOGFI("WMS-Client Save WxH = %{public}dx%{public}d", pixelMap->GetWidth(), pixelMap->GetHeight());
|
||||
} else {
|
||||
WLOGFE("Failed to get pixelmap, return nullptr!");
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "drag_controller.h"
|
||||
#include "freeze_controller.h"
|
||||
#include "singleton_delegator.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "wm_single_instance.h"
|
||||
#include "window_common_event.h"
|
||||
#include "window_controller.h"
|
||||
@ -153,6 +154,7 @@ private:
|
||||
void ConfigWindowAnimation(const std::map<std::string, WindowManagerConfig::ConfigItem>& animeMap);
|
||||
void ConfigKeyboardAnimation(const std::map<std::string, WindowManagerConfig::ConfigItem>& animeMap);
|
||||
RSAnimationTimingCurve CreateCurve(const std::map<std::string, WindowManagerConfig::ConfigItem>& timingMap);
|
||||
void RecordShowTimeEvent(int64_t costTime);
|
||||
|
||||
static inline SingletonDelegator<WindowManagerService> delegator;
|
||||
AtomicMap<uint32_t, uint32_t> accessTokenIdMaps_;
|
||||
@ -172,6 +174,7 @@ private:
|
||||
RSInterfaces& rsInterface_;
|
||||
bool startingOpen_ = true;
|
||||
std::shared_ptr<RSUIDirector> rsUiDirector_;
|
||||
ShowWindowTimeConfig showWindowTimeConfig_ = { 0, 0, 0, 0, 0 };
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "event_handler.h"
|
||||
#include "future.h"
|
||||
#include "snapshot_stub.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "window_root.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
@ -38,6 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
WMError TakeSnapshot(const std::shared_ptr<RSSurfaceNode>& surfaceNode, AAFwk::Snapshot& snapshot);
|
||||
void RecordGetSnapshotEvent(int64_t costTime);
|
||||
|
||||
private:
|
||||
float scaleW = 0.5f; // width scaling ratio(0.5)
|
||||
@ -45,6 +47,7 @@ private:
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
RSInterfaces& rsInterface_;
|
||||
GetSnapshotTimeConfig getSnapshotTimeConfig_ = { 0, 0, 0, 0, 0, 0 };
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
@ -576,7 +576,7 @@ void WindowController::RecordBootAnimationEvent() const
|
||||
{
|
||||
uint64_t time = std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::steady_clock::now()).
|
||||
time_since_epoch().count();
|
||||
WLOGFI("boot animation done duration(s): %{public}" PRIu64"", static_cast<uint64_t>(time));
|
||||
WLOGFI("boot animation done duration(s): %{public}" PRIu64"", time);
|
||||
std::ostringstream os;
|
||||
os << "boot animation done duration(s): " << time <<";";
|
||||
int32_t ret = OHOS::HiviewDFX::HiSysEvent::Write(
|
||||
|
@ -19,11 +19,14 @@
|
||||
|
||||
#include <ability_manager_client.h>
|
||||
#include <cinttypes>
|
||||
#include <chrono>
|
||||
#include <hisysevent.h>
|
||||
#include <hitrace_meter.h>
|
||||
#include <ipc_skeleton.h>
|
||||
#include <parameters.h>
|
||||
#include <rs_iwindow_animation_controller.h>
|
||||
#include <system_ability_definition.h>
|
||||
#include <sstream>
|
||||
#include "xcollie/watchdog.h"
|
||||
|
||||
#include "display_manager_service_inner.h"
|
||||
@ -44,6 +47,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowManagerService"};
|
||||
constexpr int REPORT_SHOW_WINDOW_TIMES = 50;
|
||||
}
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerService)
|
||||
|
||||
@ -543,6 +547,7 @@ WMError WindowManagerService::CreateWindow(sptr<IWindow>& window, sptr<WindowPro
|
||||
WMError WindowManagerService::AddWindow(sptr<WindowProperty>& property)
|
||||
{
|
||||
return PostSyncTask([this, &property]() {
|
||||
auto startTime = std::chrono::steady_clock::now();
|
||||
if (property == nullptr) {
|
||||
WLOGFE("property is nullptr");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
@ -557,6 +562,12 @@ WMError WindowManagerService::AddWindow(sptr<WindowProperty>& property)
|
||||
if (property->GetWindowType() == WindowType::WINDOW_TYPE_DRAGGING_EFFECT) {
|
||||
dragController_->StartDrag(windowId);
|
||||
}
|
||||
if (res == WMError::WM_OK) {
|
||||
showWindowTimeConfig_.showWindowTimes_++;
|
||||
auto currentTime = std::chrono::steady_clock::now();
|
||||
int64_t costTime = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - startTime).count();
|
||||
RecordShowTimeEvent(costTime);
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}
|
||||
@ -893,5 +904,41 @@ void WindowInfoQueriedListener::HasPrivateWindow(DisplayId displayId, bool& hasP
|
||||
WLOGFI("called");
|
||||
WindowManagerService::GetInstance().HasPrivateWindow(displayId, hasPrivateWindow);
|
||||
}
|
||||
|
||||
void WindowManagerService::RecordShowTimeEvent(int64_t costTime)
|
||||
{
|
||||
WLOGFI("show window cost time(ms): %{public}" PRIu64", show window times: %{public}u", costTime,
|
||||
showWindowTimeConfig_.showWindowTimes_.load());
|
||||
if (costTime <= 20) { // 20: means cost time is 20ms
|
||||
showWindowTimeConfig_.below20msTimes_++;
|
||||
} else if (costTime <= 35) { // 35: means cost time is 35ms
|
||||
showWindowTimeConfig_.below35msTimes_++;
|
||||
} else if (costTime <= 50) { // 50: means cost time is 50ms
|
||||
showWindowTimeConfig_.below50msTimes_++;
|
||||
} else {
|
||||
showWindowTimeConfig_.above50msTimes_++;
|
||||
}
|
||||
if (showWindowTimeConfig_.showWindowTimes_ >= REPORT_SHOW_WINDOW_TIMES) {
|
||||
std::ostringstream oss;
|
||||
oss << "show window: " << "BELOW20(ms): " << showWindowTimeConfig_.below20msTimes_
|
||||
<< ", BELOW35(ms):" << showWindowTimeConfig_.below35msTimes_
|
||||
<< ", BELOW50(ms): " << showWindowTimeConfig_.below50msTimes_
|
||||
<< ", ABOVE50(ms): " << showWindowTimeConfig_.above50msTimes_ << ";";
|
||||
int32_t ret = OHOS::HiviewDFX::HiSysEvent::Write(
|
||||
OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER,
|
||||
"SHOW_WINDOW_TIME",
|
||||
OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC,
|
||||
"MSG", oss.str());
|
||||
if (ret != 0) {
|
||||
WLOGFE("Write HiSysEvent error, ret:%{public}d", ret);
|
||||
} else {
|
||||
showWindowTimeConfig_.showWindowTimes_ = 0;
|
||||
showWindowTimeConfig_.below20msTimes_ = 0;
|
||||
showWindowTimeConfig_.below35msTimes_ = 0;
|
||||
showWindowTimeConfig_.below50msTimes_ = 0;
|
||||
showWindowTimeConfig_.above50msTimes_ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -15,7 +15,10 @@
|
||||
|
||||
#include "snapshot_controller.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <hisysevent.h>
|
||||
#include <hitrace_meter.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "surface_capture_future.h"
|
||||
#include "window_manager_hilog.h"
|
||||
@ -25,6 +28,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "SnapshotController"};
|
||||
constexpr int REPORT_SHOW_WINDOW_TIMES = 50;
|
||||
}
|
||||
|
||||
void SnapshotController::Init(sptr<WindowRoot>& root)
|
||||
@ -48,6 +52,7 @@ WMError SnapshotController::TakeSnapshot(const std::shared_ptr<RSSurfaceNode>& s
|
||||
int32_t SnapshotController::GetSnapshot(const sptr<IRemoteObject> &token, Snapshot& snapshot)
|
||||
{
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "wms:GetSnapshot");
|
||||
auto startTime = std::chrono::steady_clock::now();
|
||||
if (token == nullptr) {
|
||||
WLOGFE("Get snapshot failed, because token is null.");
|
||||
return static_cast<int32_t>(WMError::WM_ERROR_NULLPTR);
|
||||
@ -71,7 +76,54 @@ int32_t SnapshotController::GetSnapshot(const sptr<IRemoteObject> &token, Snapsh
|
||||
WLOGFE("Get surfaceNode failed, because surfaceNode is null");
|
||||
return static_cast<int32_t>(WMError::WM_ERROR_NULLPTR);
|
||||
}
|
||||
return static_cast<int32_t>(TakeSnapshot(surfaceNode, snapshot));
|
||||
WMError res = TakeSnapshot(surfaceNode, snapshot);
|
||||
if (res == WMError::WM_OK) {
|
||||
getSnapshotTimeConfig_.getSnapshotTimes_++;
|
||||
auto currentTime = std::chrono::steady_clock::now();
|
||||
int64_t costTime = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - startTime).count();
|
||||
RecordGetSnapshotEvent(costTime);
|
||||
}
|
||||
return static_cast<int32_t>(res);
|
||||
}
|
||||
|
||||
void SnapshotController::RecordGetSnapshotEvent(int64_t costTime)
|
||||
{
|
||||
WLOGFI("get snapshot cost time(ms): %{public}" PRIu64", get snapshot times: %{public}u", costTime,
|
||||
getSnapshotTimeConfig_.getSnapshotTimes_.load());
|
||||
if (costTime <= 25) { // 20: means cost time is 25ms
|
||||
getSnapshotTimeConfig_.below25msTimes_++;
|
||||
} else if (costTime <= 35) { // 35: means cost time is 35ms
|
||||
getSnapshotTimeConfig_.below35msTimes_++;
|
||||
} else if (costTime <= 50) { // 50: means cost time is 50ms
|
||||
getSnapshotTimeConfig_.below50msTimes_++;
|
||||
} else if (costTime <= 200) { // 200: means cost time is 200ms
|
||||
getSnapshotTimeConfig_.below200msTimes_++;
|
||||
} else {
|
||||
getSnapshotTimeConfig_.above200msTimes_++;
|
||||
}
|
||||
if (getSnapshotTimeConfig_.getSnapshotTimes_ >= REPORT_SHOW_WINDOW_TIMES) {
|
||||
std::ostringstream oss;
|
||||
oss << "show window: " << "BELOW25(ms): " << getSnapshotTimeConfig_.below25msTimes_
|
||||
<< ", BELOW35(ms):" << getSnapshotTimeConfig_.below35msTimes_
|
||||
<< ", BELOW50(ms): " << getSnapshotTimeConfig_.below50msTimes_
|
||||
<< ", BELOW200(ms): " << getSnapshotTimeConfig_.below200msTimes_
|
||||
<< ", ABOVE50(ms): " << getSnapshotTimeConfig_.above200msTimes_ << ";";
|
||||
int32_t ret = OHOS::HiviewDFX::HiSysEvent::Write(
|
||||
OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER,
|
||||
"GET_SNAPSHOT_TIME",
|
||||
OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC,
|
||||
"MSG", oss.str());
|
||||
if (ret != 0) {
|
||||
WLOGFE("Write HiSysEvent error, ret:%{public}d", ret);
|
||||
} else {
|
||||
getSnapshotTimeConfig_.getSnapshotTimes_ = 0;
|
||||
getSnapshotTimeConfig_.below25msTimes_ = 0;
|
||||
getSnapshotTimeConfig_.below35msTimes_ = 0;
|
||||
getSnapshotTimeConfig_.below50msTimes_ = 0;
|
||||
getSnapshotTimeConfig_.below200msTimes_ = 0;
|
||||
getSnapshotTimeConfig_.above200msTimes_ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
Loading…
x
Reference in New Issue
Block a user