From 24791621ca30edb3cb676ba04db89689d1865452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=9E=E5=AE=87=E6=88=90?= Date: Wed, 11 Sep 2024 21:23:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?ArkWeb=E5=86=85=E6=A0=B8=E5=AF=B9dmp?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=94=B9=E9=80=A0=E5=88=B0=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 庞宇成 --- ohos_nweb/src/cef_delegate/nweb_delegate.cc | 5 ++ .../src/cef_delegate/nweb_handler_delegate.cc | 4 + ohos_nweb/src/nweb_impl.cc | 25 ++++++ ohos_nweb/src/nweb_impl.h | 4 + ohos_nweb/src/sysevent/event_reporter.cc | 85 ++++++++++++++++++- ohos_nweb/src/sysevent/event_reporter.h | 13 +++ 6 files changed, 135 insertions(+), 1 deletion(-) diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index ffc4cdd39c..87afa3d8f2 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -456,6 +456,11 @@ bool NWebDelegate::Init(bool is_enhance_surface, // background color should set when init in case of first white screen flash preference_delegate_->SetBackgroundColor(backgroundColor); } + +#ifdef OHOS_CRASHPAD + ReportTransferToBaseStorage(); +#endif + #ifdef OHOS_DRAG_DROP InitAppTempDir(); #endif diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc index 296d3be358..4b0d58e4bc 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc @@ -1618,6 +1618,10 @@ void NWebHandlerDelegate::OnRenderProcessTerminated( ReportPageLoadErrorInfo(nweb_id_, error_type, static_cast(reason), error_desc); #endif + +#if defined(OHOS_CRASHPAD) + ReportTransferToBaseStorage(); +#endif } bool NWebHandlerDelegate::GetAuthCredentials( diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 5a24004c4e..41d2f634da 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -176,6 +176,10 @@ extern bool g_siteIsolationMode; #include "content/browser/gpu/gpu_process_host.h" #endif +#ifdef OHOS_CRASHPAD +#include "event_reporter.h" +#endif + namespace { uint32_t g_nweb_count = 0; const uint32_t kSurfaceMaxWidth = 7680; @@ -2849,6 +2853,27 @@ void NWebImpl::PutLoggerCallback( std::shared_ptr logger_callback) { WVLOG_D("put logger callback"); g_logger_callback = logger_callback; +#ifdef OHOS_CRASHPAD +void NWebImpl::SetDefaultCrashpadLogPath(const std::string& crashpadLogPath) { + SetTargetCrashpadLogPath(crashpadLogPath); +} +#endif + +bool NWebImpl::Discard() { + if (nweb_delegate_ == nullptr) { + WVLOG_E("Discard failed, nweb delegate is nullptr, nweb_id = %{public}u", nweb_id_); + return false; + } + + if (!nweb_delegate_->Discard()) { + return false; + } + + WVLOG_D("Discard: Notify the bufferq to clean all caches"); + OHOS::NWeb::OhosAdapterHelper::GetInstance() + .GetWindowAdapterInstance() + .NativeWindowSurfaceCleanCacheWithPara(reinterpret_cast(window_), true); + return true; } void NWebImpl::RemoveLoggerCallback() { diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index 752920b8db..766222335c 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -472,6 +472,10 @@ class NWebImpl : public NWeb { double GetBrowserZoomLevel() const; #endif +#ifdef OHOS_CRASHPAD + void SetDefaultCrashpadLogPath(const std::string& crashpadLogPath); +#endif + #if defined(OHOS_INCOGNITO_MODE) bool IsIncognitoMode() override { return incognito_mode_; diff --git a/ohos_nweb/src/sysevent/event_reporter.cc b/ohos_nweb/src/sysevent/event_reporter.cc index 121ff56389..f2ffad586f 100644 --- a/ohos_nweb/src/sysevent/event_reporter.cc +++ b/ohos_nweb/src/sysevent/event_reporter.cc @@ -82,9 +82,17 @@ constexpr char TOTAL_APP_MISSED_FRAMES[] = "TOTAL_APP_MISSED_FRAMES"; constexpr char MAX_APP_FRAMETIME[] = "MAX_APP_FRAMETIME"; constexpr char MAX_APP_SEQ_MISSSED_FRAMES[] = "MAX_APP_SEQ_MISSSED_FRAMES"; -// For site_isolation +// For site_isolation constexpr char SITE_ISOLATION_MODE[] = "SITE_ISOLATION_MODE"; constexpr char SITE_ISOLATION_STATUS[] = "SITE_ISOLATION_STATUS"; + +// For crashpad info +#if defined(OHOS_CRASHPAD) +constexpr char DEFAULT_CRASHPAD_ORIGIN_LOCATION[] = "/data/storage/el2/log/crashpad/"; +constexpr char DEFAULT_CRASHPAD_TARGET_LOCATION[] = "/data/storage/el2/base/crashpad"; +static std::string crashpadTargetLocation = "/data/storage/el2/base/crashpad"; +#endif + } // namespace void ReportPageLoadStats(int instanceId, @@ -260,3 +268,78 @@ void ReportSiteIsolationMode(const std::string site_isolation_status) { OhosAdapterHelper::GetInstance().GetHiSysEventAdapterInstance().Write( SITE_ISOLATION_MODE, HiSysEventAdapter::EventType::BEHAVIOR, {SITE_ISOLATION_STATUS, site_isolation_status}); } + + +#if defined(OHOS_CRASHPAD) +void MoveDirectory(const base::FilePath& from_dir, + const base::FilePath& to_dir) { + if (!base::DirectoryExists(from_dir)) { + LOG(ERROR) << "Source directory does not exist: " << from_dir.value(); + return; + } + if (!base::CreateDirectory(to_dir)) { + LOG(ERROR) << "Failed to create target directory: " << to_dir.value(); + return; + } + + // Move all files in the current directory. + base::FileEnumerator enumerator(from_dir, false, base::FileEnumerator::FILES); + for (base::FilePath path = enumerator.Next(); !path.empty(); + path = enumerator.Next()) { + base::FilePath target_path = to_dir.Append(path.BaseName()); + if (!base::Move(path, target_path)) { + LOG(ERROR) << "Failed to move file: " << path.value() << " to " + << target_path.value(); + } else { + LOG(INFO) << "Moved file: " << path.value() << " to " + << target_path.value(); + } + } + // Recursively move all subdirectories. + base::FileEnumerator enumeratorSubDir = + base::FileEnumerator(from_dir, true, base::FileEnumerator::DIRECTORIES); + for (base::FilePath path = enumeratorSubDir.Next(); !path.empty(); + path = enumeratorSubDir.Next()) { + base::FilePath target_path = to_dir.Append(path.BaseName()); + MoveDirectory(path, target_path); + } +} + +void SetTargetCrashpadLogPath(std::string crashpadLogPath) { + LOG(INFO) << "crashpadTargetLocation is " << crashpadTargetLocation + << " crashpadLogPath is " << crashpadLogPath; + crashpadTargetLocation = crashpadLogPath; +} +void TransferToTargetFile(const base::FilePath& from_dir, + const base::FilePath& to_dir) { + bool isParentOrSelfPath = to_dir.IsParent(from_dir) || to_dir == from_dir; + if (!base::PathExists(to_dir) || isParentOrSelfPath) { + LOG(WARNING) << "to_dir file path is no illegal, this input to_dir is " + << to_dir; + MoveDirectory( + from_dir, + base::FilePath(FILE_PATH_LITERAL(DEFAULT_CRASHPAD_TARGET_LOCATION))); + return; + } + MoveDirectory(from_dir, to_dir); +} +void ReportTransferToBaseStorage() { + LOG(INFO) + << "Start ReportTransferToBaseStorage .... crashpadTargetLocation is " + << crashpadTargetLocation; + if (!(base::CommandLine::ForCurrentProcess() && + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kForBrowser))) { + LOG(WARNING) << "return ReportTransferToBaseStorage fail cause brower has " + "no start crashpadTargetLocation is " + << crashpadTargetLocation; + return; + } + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce( + &TransferToTargetFile, + base::FilePath(FILE_PATH_LITERAL(DEFAULT_CRASHPAD_ORIGIN_LOCATION)), + base::FilePath(FILE_PATH_LITERAL(crashpadTargetLocation)))); +} +#endif diff --git a/ohos_nweb/src/sysevent/event_reporter.h b/ohos_nweb/src/sysevent/event_reporter.h index d76e09dbaf..1a87fd7370 100644 --- a/ohos_nweb/src/sysevent/event_reporter.h +++ b/ohos_nweb/src/sysevent/event_reporter.h @@ -19,6 +19,13 @@ #include #include #include "oh_web_performance_timing.h" +#include "base/files/file_util.h" +#include "base/files/file_enumerator.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/command_line.h" +#include "content/public/common/content_switches.h" +#include "content/public/browser/browser_thread.h" void ReportPageLoadStats(int instanceId, int accessSumCount, @@ -68,4 +75,10 @@ void ReportSlideJankStats(int64_t startTime, int64_t duration, int32_t totalAppF int32_t totalAppMissedFrames, int64_t maxAppFrametime, int32_t maxAppSeqMissedFrames); void ReportSiteIsolationMode(const std::string site_isolation_status); + +#if defined(OHOS_CRASHPAD) +void SetTargetCrashpadLogPath(std::string crashpadLogPath); +void ReportTransferToBaseStorage(void); +#endif + #endif -- Gitee From eee379277f2b5f8904a10f1d6188a22f8def1dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=9E=E5=AE=87=E6=88=90?= Date: Fri, 20 Sep 2024 18:39:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=87=BA=E5=86=85=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: diaogaoyang --- .../src/cef_delegate/nweb_application.cc | 8 ++ ohos_nweb/src/cef_delegate/nweb_delegate.cc | 5 -- .../src/cef_delegate/nweb_handler_delegate.cc | 4 - ohos_nweb/src/nweb_impl.cc | 16 ++-- ohos_nweb/src/nweb_impl.h | 3 +- ohos_nweb/src/sysevent/event_reporter.cc | 84 +------------------ ohos_nweb/src/sysevent/event_reporter.h | 13 --- 7 files changed, 21 insertions(+), 112 deletions(-) diff --git a/ohos_nweb/src/cef_delegate/nweb_application.cc b/ohos_nweb/src/cef_delegate/nweb_application.cc index 716dd0b406..00287493aa 100644 --- a/ohos_nweb/src/cef_delegate/nweb_application.cc +++ b/ohos_nweb/src/cef_delegate/nweb_application.cc @@ -35,6 +35,10 @@ #include "cef/libcef/common/net/scheme_registration.h" #endif +#ifdef defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) +#include "ohos_nweb_ex/overrides/ohos_nweb/src/cef_delegate/custom_crashpad_handler.h" +#endif + namespace { #if defined(OHOS_API_INIT_WEB_ENGINE) CefRefPtr g_application = nullptr; @@ -95,6 +99,10 @@ void NWebApplication::InitializeCef(const CefMainArgs& mainargs, } #endif // defined(OHOS_API_INIT_WEB_ENGINE) +#ifdef defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) +OHOS::NWeb::ReportCrashpadFiles(NWebImpl::GetDefaultCrashpadLogPath()); +#endif + /* CefApp methods begin */ CefRefPtr NWebApplication::GetBrowserProcessHandler() { diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index 87afa3d8f2..ffc4cdd39c 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -456,11 +456,6 @@ bool NWebDelegate::Init(bool is_enhance_surface, // background color should set when init in case of first white screen flash preference_delegate_->SetBackgroundColor(backgroundColor); } - -#ifdef OHOS_CRASHPAD - ReportTransferToBaseStorage(); -#endif - #ifdef OHOS_DRAG_DROP InitAppTempDir(); #endif diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc index 4b0d58e4bc..296d3be358 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc @@ -1618,10 +1618,6 @@ void NWebHandlerDelegate::OnRenderProcessTerminated( ReportPageLoadErrorInfo(nweb_id_, error_type, static_cast(reason), error_desc); #endif - -#if defined(OHOS_CRASHPAD) - ReportTransferToBaseStorage(); -#endif } bool NWebHandlerDelegate::GetAuthCredentials( diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 41d2f634da..59904f0f2d 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -176,10 +176,6 @@ extern bool g_siteIsolationMode; #include "content/browser/gpu/gpu_process_host.h" #endif -#ifdef OHOS_CRASHPAD -#include "event_reporter.h" -#endif - namespace { uint32_t g_nweb_count = 0; const uint32_t kSurfaceMaxWidth = 7680; @@ -216,6 +212,9 @@ static bool set_whole_page_drawing = false; std::shared_ptr g_logger_callback; #endif bool g_logger_callback_initialized = false; +#if defined(OHOS_CRASHPAD) +static std::string g_crashpad_target_location = "/data/storage/el2/crashpad"; +#endif bool GetWebOptimizationValue() { auto& system_properties_adapter = OHOS::NWeb::OhosAdapterHelper::GetInstance() @@ -2854,8 +2853,13 @@ void NWebImpl::PutLoggerCallback( WVLOG_D("put logger callback"); g_logger_callback = logger_callback; #ifdef OHOS_CRASHPAD -void NWebImpl::SetDefaultCrashpadLogPath(const std::string& crashpadLogPath) { - SetTargetCrashpadLogPath(crashpadLogPath); +void NWebImpl::SetDefaultCrashpadLogPath(const std::string& crashpad_log_path) { + LOG(INFO) << "g_crashpad_target_location is" << g_crashpad_target_location + << "crashpad_log_path is" << crashpad_log_path; + g_crashpad_target_location = crashpad_log_path; +} +const std::string NWebImpl::GetDefaultCrashpadLogPath() { + return g_crashpad_target_location; } #endif diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index 766222335c..e2fd6291a1 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -473,7 +473,8 @@ class NWebImpl : public NWeb { #endif #ifdef OHOS_CRASHPAD - void SetDefaultCrashpadLogPath(const std::string& crashpadLogPath); + static void SetDefaultCrashpadLogPath(const std::string& crashpad_log_path); + static const std::string GetDefaultCrashpadLogPath(); #endif #if defined(OHOS_INCOGNITO_MODE) diff --git a/ohos_nweb/src/sysevent/event_reporter.cc b/ohos_nweb/src/sysevent/event_reporter.cc index f2ffad586f..dff6e7a7f0 100644 --- a/ohos_nweb/src/sysevent/event_reporter.cc +++ b/ohos_nweb/src/sysevent/event_reporter.cc @@ -86,13 +86,6 @@ constexpr char MAX_APP_SEQ_MISSSED_FRAMES[] = "MAX_APP_SEQ_MISSSED_FRAMES"; constexpr char SITE_ISOLATION_MODE[] = "SITE_ISOLATION_MODE"; constexpr char SITE_ISOLATION_STATUS[] = "SITE_ISOLATION_STATUS"; -// For crashpad info -#if defined(OHOS_CRASHPAD) -constexpr char DEFAULT_CRASHPAD_ORIGIN_LOCATION[] = "/data/storage/el2/log/crashpad/"; -constexpr char DEFAULT_CRASHPAD_TARGET_LOCATION[] = "/data/storage/el2/base/crashpad"; -static std::string crashpadTargetLocation = "/data/storage/el2/base/crashpad"; -#endif - } // namespace void ReportPageLoadStats(int instanceId, @@ -267,79 +260,4 @@ void ReportSlideJankStats(int64_t startTime, int64_t duration, int32_t totalAppF void ReportSiteIsolationMode(const std::string site_isolation_status) { OhosAdapterHelper::GetInstance().GetHiSysEventAdapterInstance().Write( SITE_ISOLATION_MODE, HiSysEventAdapter::EventType::BEHAVIOR, {SITE_ISOLATION_STATUS, site_isolation_status}); -} - - -#if defined(OHOS_CRASHPAD) -void MoveDirectory(const base::FilePath& from_dir, - const base::FilePath& to_dir) { - if (!base::DirectoryExists(from_dir)) { - LOG(ERROR) << "Source directory does not exist: " << from_dir.value(); - return; - } - if (!base::CreateDirectory(to_dir)) { - LOG(ERROR) << "Failed to create target directory: " << to_dir.value(); - return; - } - - // Move all files in the current directory. - base::FileEnumerator enumerator(from_dir, false, base::FileEnumerator::FILES); - for (base::FilePath path = enumerator.Next(); !path.empty(); - path = enumerator.Next()) { - base::FilePath target_path = to_dir.Append(path.BaseName()); - if (!base::Move(path, target_path)) { - LOG(ERROR) << "Failed to move file: " << path.value() << " to " - << target_path.value(); - } else { - LOG(INFO) << "Moved file: " << path.value() << " to " - << target_path.value(); - } - } - // Recursively move all subdirectories. - base::FileEnumerator enumeratorSubDir = - base::FileEnumerator(from_dir, true, base::FileEnumerator::DIRECTORIES); - for (base::FilePath path = enumeratorSubDir.Next(); !path.empty(); - path = enumeratorSubDir.Next()) { - base::FilePath target_path = to_dir.Append(path.BaseName()); - MoveDirectory(path, target_path); - } -} - -void SetTargetCrashpadLogPath(std::string crashpadLogPath) { - LOG(INFO) << "crashpadTargetLocation is " << crashpadTargetLocation - << " crashpadLogPath is " << crashpadLogPath; - crashpadTargetLocation = crashpadLogPath; -} -void TransferToTargetFile(const base::FilePath& from_dir, - const base::FilePath& to_dir) { - bool isParentOrSelfPath = to_dir.IsParent(from_dir) || to_dir == from_dir; - if (!base::PathExists(to_dir) || isParentOrSelfPath) { - LOG(WARNING) << "to_dir file path is no illegal, this input to_dir is " - << to_dir; - MoveDirectory( - from_dir, - base::FilePath(FILE_PATH_LITERAL(DEFAULT_CRASHPAD_TARGET_LOCATION))); - return; - } - MoveDirectory(from_dir, to_dir); -} -void ReportTransferToBaseStorage() { - LOG(INFO) - << "Start ReportTransferToBaseStorage .... crashpadTargetLocation is " - << crashpadTargetLocation; - if (!(base::CommandLine::ForCurrentProcess() && - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kForBrowser))) { - LOG(WARNING) << "return ReportTransferToBaseStorage fail cause brower has " - "no start crashpadTargetLocation is " - << crashpadTargetLocation; - return; - } - content::GetIOThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce( - &TransferToTargetFile, - base::FilePath(FILE_PATH_LITERAL(DEFAULT_CRASHPAD_ORIGIN_LOCATION)), - base::FilePath(FILE_PATH_LITERAL(crashpadTargetLocation)))); -} -#endif +} \ No newline at end of file diff --git a/ohos_nweb/src/sysevent/event_reporter.h b/ohos_nweb/src/sysevent/event_reporter.h index 1a87fd7370..d76e09dbaf 100644 --- a/ohos_nweb/src/sysevent/event_reporter.h +++ b/ohos_nweb/src/sysevent/event_reporter.h @@ -19,13 +19,6 @@ #include #include #include "oh_web_performance_timing.h" -#include "base/files/file_util.h" -#include "base/files/file_enumerator.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/command_line.h" -#include "content/public/common/content_switches.h" -#include "content/public/browser/browser_thread.h" void ReportPageLoadStats(int instanceId, int accessSumCount, @@ -75,10 +68,4 @@ void ReportSlideJankStats(int64_t startTime, int64_t duration, int32_t totalAppF int32_t totalAppMissedFrames, int64_t maxAppFrametime, int32_t maxAppSeqMissedFrames); void ReportSiteIsolationMode(const std::string site_isolation_status); - -#if defined(OHOS_CRASHPAD) -void SetTargetCrashpadLogPath(std::string crashpadLogPath); -void ReportTransferToBaseStorage(void); -#endif - #endif -- Gitee From cc7a2b36a8159a30cf129242fe6fcc70f602b648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=9E=E5=AE=87=E6=88=90?= Date: Wed, 16 Oct 2024 16:58:04 +0800 Subject: [PATCH 3/3] upload dmp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 庞宇成 --- .../src/cef_delegate/nweb_handler_delegate.cc | 8 ++++++ ohos_nweb/src/nweb_impl.cc | 26 ++++++++----------- ohos_nweb/src/nweb_impl.h | 3 +++ ohos_nweb/src/sysevent/event_reporter.cc | 5 ++-- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc index 296d3be358..b3c49ccdd2 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc @@ -113,6 +113,9 @@ #ifdef OHOS_ARKWEB_ADBLOCK #include "base/strings/string_number_conversions.h" #endif +#if defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) +#include "ohos_nweb_ex/overrides/ohos_nweb/src/cef_delegate/custom_crashpad_handler.h" +#endif #include "third_party/bounds_checking_function/include/securec.h" @@ -1618,6 +1621,11 @@ void NWebHandlerDelegate::OnRenderProcessTerminated( ReportPageLoadErrorInfo(nweb_id_, error_type, static_cast(reason), error_desc); #endif + +#if defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) + OHOS::NWeb::ReportFeedbacklogsCrashDmpFiles( + NWebImpl::GetDefaultFeedbacklogsCrashPath()); +#endif } bool NWebHandlerDelegate::GetAuthCredentials( diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 59904f0f2d..a1afe5fe59 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -214,6 +214,8 @@ std::shared_ptr g_logger_callback; bool g_logger_callback_initialized = false; #if defined(OHOS_CRASHPAD) static std::string g_crashpad_target_location = "/data/storage/el2/crashpad"; +static std::string g_feedbacklogs_crash_path = + "/data/storage/el2/base/haps/entry/files/logs/logs/logFile"; #endif bool GetWebOptimizationValue() { @@ -2861,24 +2863,18 @@ void NWebImpl::SetDefaultCrashpadLogPath(const std::string& crashpad_log_path) { const std::string NWebImpl::GetDefaultCrashpadLogPath() { return g_crashpad_target_location; } -#endif -bool NWebImpl::Discard() { - if (nweb_delegate_ == nullptr) { - WVLOG_E("Discard failed, nweb delegate is nullptr, nweb_id = %{public}u", nweb_id_); - return false; - } - - if (!nweb_delegate_->Discard()) { - return false; - } +void NWebImpl::SetDefaultFeedbacklogsCrashPath( + const std::string& feedbacklogs_crash_path) { + LOG(INFO) << "[feedbacklogs] g_feedbacklogs_crash_path: " << g_feedbacklogs_crash_path + << ", feedbacklogs_crash_path: " << feedbacklogs_crash_path; + g_feedbacklogs_crash_path = feedbacklogs_crash_path; +} - WVLOG_D("Discard: Notify the bufferq to clean all caches"); - OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetWindowAdapterInstance() - .NativeWindowSurfaceCleanCacheWithPara(reinterpret_cast(window_), true); - return true; +const std::string& NWebImpl::GetDefaultFeedbacklogsCrashPath() { + return g_feedbacklogs_crash_path; } +#endif void NWebImpl::RemoveLoggerCallback() { WVLOG_D("remove logger callback"); diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index e2fd6291a1..8cd5a10fdb 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -475,6 +475,9 @@ class NWebImpl : public NWeb { #ifdef OHOS_CRASHPAD static void SetDefaultCrashpadLogPath(const std::string& crashpad_log_path); static const std::string GetDefaultCrashpadLogPath(); + static void SetDefaultFeedbacklogsCrashPath( + const std::string& feedbacklogs_crash_path); + static const std::string& GetDefaultFeedbacklogsCrashPath(); #endif #if defined(OHOS_INCOGNITO_MODE) diff --git a/ohos_nweb/src/sysevent/event_reporter.cc b/ohos_nweb/src/sysevent/event_reporter.cc index dff6e7a7f0..121ff56389 100644 --- a/ohos_nweb/src/sysevent/event_reporter.cc +++ b/ohos_nweb/src/sysevent/event_reporter.cc @@ -82,10 +82,9 @@ constexpr char TOTAL_APP_MISSED_FRAMES[] = "TOTAL_APP_MISSED_FRAMES"; constexpr char MAX_APP_FRAMETIME[] = "MAX_APP_FRAMETIME"; constexpr char MAX_APP_SEQ_MISSSED_FRAMES[] = "MAX_APP_SEQ_MISSSED_FRAMES"; -// For site_isolation +// For site_isolation constexpr char SITE_ISOLATION_MODE[] = "SITE_ISOLATION_MODE"; constexpr char SITE_ISOLATION_STATUS[] = "SITE_ISOLATION_STATUS"; - } // namespace void ReportPageLoadStats(int instanceId, @@ -260,4 +259,4 @@ void ReportSlideJankStats(int64_t startTime, int64_t duration, int32_t totalAppF void ReportSiteIsolationMode(const std::string site_isolation_status) { OhosAdapterHelper::GetInstance().GetHiSysEventAdapterInstance().Write( SITE_ISOLATION_MODE, HiSysEventAdapter::EventType::BEHAVIOR, {SITE_ISOLATION_STATUS, site_isolation_status}); -} \ No newline at end of file +} -- Gitee