1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H 18 19 #include <string> 20 #include <vector> 21 22 #include "base/perfmonitor/perf_monitor.h" 23 #include "base/utils/macros.h" 24 25 namespace OHOS::Ace { 26 27 const std::string EXCEPTION_FRAMEWORK_APP_START = "FRAMEWORK_APP_START_EXCEPTION"; 28 const std::string EXCEPTION_FRAMEWORK_PAGE_ROUTER = "FRAMEWORK_PAGE_ROUTER_EXCEPTION"; 29 const std::string EXCEPTION_COMPONENT = "COMPONENT_EXCEPTION"; 30 const std::string EXCEPTION_API_CHANNEL = "API_CHANNEL_EXCEPTION"; 31 const std::string EXCEPTION_RENDER = "RENDER_EXCEPTION"; 32 const std::string EXCEPTION_JS = "JS_EXCEPTION"; 33 const std::string EXCEPTION_ANIMATION = "ANIMATION_EXCEPTION"; 34 const std::string EXCEPTION_EVENT = "EVENT_EXCEPTION"; 35 const std::string EXCEPTION_INTERNATIONALIZATION = "INTERNATIONALIZATION_EXCEPTION"; 36 const std::string EXCEPTION_ACCESSIBILITY = "ACCESSIBILITY_EXCEPTION"; 37 const std::string EXCEPTION_FORM = "FORM_EXCEPTION"; 38 39 // EXCEPTION_FRAMEWORK_APP_START 40 enum class AppStartExcepType { 41 CREATE_CONTAINER_ERR = 1, 42 SET_VIEW_ERR, 43 VIEW_TYPE_ERR, 44 GET_PACKAGE_PATH_ERR, 45 JNI_CLASS_ERR, 46 JNI_INIT_ERR = 10, 47 FRONTEND_TYPE_ERR, 48 PIPELINE_CONTEXT_ERR, 49 VIEW_STATE_ERR, 50 RESOURCE_REGISTER_INIT_ERR, 51 JS_ENGINE_CREATE_ERR, 52 JAVA_EVENT_CALLBACK_INIT_ERR, 53 }; 54 55 // EXCEPTION_FRAMEWORK_PAGE_ROUTER 56 enum class PageRouterExcepType { 57 ROUTE_PARSE_ERR = 0, 58 PAGE_STACK_OVERFLOW_ERR, 59 RUN_PAGE_ERR, 60 UPDATE_PAGE_ERR, 61 LOAD_PAGE_ERR, 62 REPLACE_PAGE_ERR, 63 }; 64 65 // EXCEPTION_COMPONENT 66 enum class ComponentExcepType { 67 TEXT_INPUT_CONNECTION_CLOSE_ERR = 0, 68 GET_THEME_ERR, 69 BUTTON_COMPONENT_ERR, 70 DIALOG_EVENT_ERR, 71 DOM_NODE_NOT_FOUND, 72 SET_ROOT_DOM_NODE_ERR, 73 IMAGE_ANIMATOR_ERR, 74 LIST_COMPONENT_ERR, 75 LIST_ITEM_ERR, 76 MARQUEE_ERR, 77 NAVIGATION_BAR_ERR, 78 }; 79 80 // EXCEPTION_API_CHANNEL 81 enum class APIChannelExcepType { 82 JS_BRIDGE_INIT_ERR = 0, 83 SET_FUNCTION_ERR, 84 }; 85 86 // EXCEPTION_RENDER 87 enum class RenderExcepType { 88 VIEW_SCALE_ERR = 0, 89 RENDER_ANIMATION_ERR, 90 RENDER_COMPONENT_ERR, 91 CLIP_ERR, 92 UI_THREAD_STUCK, 93 }; 94 95 // EXCEPTION_JS 96 enum class JsExcepType { 97 GET_NODE_ERR = 0, 98 CREATE_NODE_ERR, 99 CREATE_DOM_BODY_ERR, 100 REMOVE_DOM_ELEMENT_ERR, 101 UPDATE_DOM_ELEMENT_ERR, 102 JS_ENGINE_INIT_ERR, 103 JS_RUNTIME_OBJ_ERR, 104 JS_CONTEXT_INIT_ERR, 105 JS_THREAD_STUCK, 106 }; 107 108 // EXCEPTION_ANIMATION 109 enum class AnimationExcepType { 110 ANIMATION_BRIDGE_ERR = 0, 111 ANIMATION_PAGE_ERR, 112 }; 113 114 // EXCEPTION_EVENT 115 enum class EventExcepType { 116 FIRE_EVENT_ERR = 1, 117 }; 118 119 // EXCEPTION_INTERNATIONALIZATION 120 enum class InternalExcepType { 121 CHANGE_LOCALE_ERR = 0, 122 }; 123 124 // EXCEPTION_ACCESSIBILITY 125 enum class AccessibilityExcepType { 126 CREATE_ACCESSIBILITY_NODE_ERR = 0, 127 GET_NODE_ERR, 128 }; 129 130 // EXCEPTION_FORM 131 enum class FormExcepType { 132 RUN_PAGE_ERR = 0, 133 LOAD_PAGE_ERR, 134 CREATE_NODE_ERR, 135 UPDATE_PAGE_ERR, 136 FIRE_FORM_EVENT_ERR, 137 ACTION_EVENT_CALLBACK_ERR, 138 }; 139 140 #ifdef VSYNC_TIMEOUT_CHECK 141 enum class VsyncExcepType { 142 UI_VSYNC_TIMEOUT 143 }; 144 #endif 145 146 enum class RawEventType { WARNING, FREEZE, RECOVER }; 147 148 struct EventInfo { 149 std::string eventType; 150 int32_t errorType = 0; 151 std::string pageUrl; 152 }; 153 154 struct DragInfo { 155 int32_t isCrossing = -1; 156 int32_t result = -1; 157 int32_t summaryNum = -1; 158 std::string dragBehavior; 159 std::string pNameId; 160 std::string pVersionId; 161 std::string hostName; 162 std::string summaryType; 163 std::string allowDropType; 164 }; 165 166 class ACE_FORCE_EXPORT EventReport { 167 public: 168 static void SendEvent(const EventInfo& eventInfo); 169 static void SendJsCardRenderTimeEvent( 170 const std::string& sessionID, 171 const std::string& timeType, 172 uint64_t timeDelay); 173 174 static void SendAppStartException(AppStartExcepType type); 175 static void SendPageRouterException(PageRouterExcepType type, const std::string& pageUrl = ""); 176 static void SendComponentException(ComponentExcepType type); 177 static void SendAPIChannelException(APIChannelExcepType type); 178 static void SendRenderException(RenderExcepType type); 179 static void SendJsException(JsExcepType type); 180 static void SendAnimationException(AnimationExcepType type); 181 static void SendEventException(EventExcepType type); 182 static void SendInternalException(InternalExcepType type); 183 static void SendAccessibilityException(AccessibilityExcepType type); 184 static void SendFormException(FormExcepType type); 185 #ifdef VSYNC_TIMEOUT_CHECK 186 static void SendVsyncException(VsyncExcepType type, uint32_t windowId, int32_t instanceId, uint64_t timeStamp); 187 #endif 188 189 static void JsEventReport(int32_t eventType, const std::string& jsonStr); 190 static void JsErrReport( 191 const std::string& packageName, const std::string& reason, const std::string& summary); 192 static void ANRRawReport(RawEventType type, int32_t uid, const std::string& packageName, 193 const std::string& processName, const std::string& msg = " "); 194 static void ANRShowDialog(int32_t uid, const std::string& packageName, 195 const std::string& processName, const std::string& msg = ""); 196 static void JankFrameReport(int64_t startTime, int64_t duration, const std::vector<uint16_t>& jank, 197 const std::string& pageUrl, uint32_t jankStatusVersion = 1); 198 static void ReportEventComplete(DataBase& data); 199 static void ReportEventJankFrame(DataBase& data); 200 static void ReportJankFrameApp(JankInfo& info); 201 static void ReportJankFrameFiltered(JankInfo& info); 202 static void ReportJankFrameUnFiltered(JankInfo& info); 203 static void ReportDoubleClickTitle(int32_t stateChange); 204 static void ReportClickTitleMaximizeMenu(int32_t maxMenuItem, int32_t stateChange); 205 static void ReportPageNodeOverflow(const std::string& pageUrl, int32_t nodeCount, int32_t threshold); 206 static void ReportPageDepthOverflow(const std::string& pageUrl, int32_t depth, int32_t threshold); 207 static void ReportFunctionTimeout(const std::string& functionName, int64_t time, int32_t threshold); 208 static void ReportHoverStatusChange(int32_t foldStatus, int32_t time, bool isHoverMode, 209 int32_t appRotation, int32_t windowMode); 210 static void ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName, 211 const std::string& pageName); 212 static void ReportDragInfo(const DragInfo& dragInfo); 213 214 private: 215 static void SendEventInner(const EventInfo& eventInfo); 216 #ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE 217 static void ReportAppFrameDropToRss(const bool isInteractionJank, const std::string &bundleName, 218 const int64_t maxFrameTime = 0); 219 #endif // RESOURCE_SCHEDULE_SERVICE_ENABLE 220 }; 221 222 } // namespace OHOS::Ace 223 224 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_LOG_EVENT_REPORT_H 225