!42334 【web】Web渲染-新增DFX调试手段

Merge pull request !42334 from LvJunMao/add-debug-sysparameter
This commit is contained in:
openharmony_ci 2024-09-04 09:24:12 +00:00 committed by Gitee
commit 4bca2237ae
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 52 additions and 5 deletions

View File

@ -881,4 +881,9 @@ void SystemProperties::InitFoldScreenTypeBySystemProperty()
foldScreenType_ = static_cast<FoldScreenType>(type);
}
}
std::string SystemProperties::GetWebDebugRenderMode()
{
return OHOS::system::GetParameter("web.debug.renderMode", "");
}
} // namespace OHOS::Ace

View File

@ -589,6 +589,8 @@ public:
static bool IsSmallFoldProduct();
static std::string GetWebDebugRenderMode();
private:
static bool opincEnabled_;
static bool developerModeOn_;

View File

@ -24,6 +24,7 @@
#include "base/log/ace_scoring_log.h"
#include "base/memory/ace_type.h"
#include "base/memory/referenced.h"
#include "base/utils/system_properties.h"
#include "base/utils/utils.h"
#if !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM)
#include "base/web/webview/ohos_nweb/include/nweb.h"
@ -2269,6 +2270,18 @@ void JSWeb::Create(const JSCallbackInfo& info)
if (type->IsNumber() && (type->ToNumber<int32_t>() >= 0) && (type->ToNumber<int32_t>() <= 1)) {
renderMode = static_cast<RenderMode>(type->ToNumber<int32_t>());
}
std::string debugRenderMode = SystemProperties::GetWebDebugRenderMode();
if (debugRenderMode != "none") {
if (debugRenderMode == "async") {
renderMode = RenderMode::ASYNC_RENDER;
} else if (debugRenderMode == "sync") {
renderMode = RenderMode::SYNC_RENDER;
} else {
TAG_LOGW(AceLogTag::ACE_WEB, "JSWeb::Create unsupport debug render mode: %{public}s",
debugRenderMode.c_str());
}
TAG_LOGI(AceLogTag::ACE_WEB, "JSWeb::Create use debug render mode: %{public}s", debugRenderMode.c_str());
}
bool incognitoMode = false;
ParseJsBool(paramObject->GetProperty("incognitoMode"), incognitoMode);

View File

@ -30,6 +30,8 @@ CanvasDrawFunction WebPaintMethod::GetForegroundDrawFunction(PaintWrapper* paint
CHECK_NULL_VOID(painter);
auto surface = DynamicCast<NG::RosenRenderSurface>(painter->renderSuface_);
if (surface) {
ACE_SCOPED_TRACE("WebPaintMethod::GetForegroundDrawFunction Web DrawBuffer (width %d, height %d)",
width, height);
surface->DrawBuffer(width, height);
}
};

View File

@ -233,6 +233,11 @@ const std::map<std::string, OHOS::NWeb::NWebAutofillEvent> NWEB_AUTOFILL_EVENTS
{OHOS::NWeb::NWEB_AUTOFILL_EVENT_UPDATE, OHOS::NWeb::NWebAutofillEvent::UPDATE},
{OHOS::NWeb::NWEB_AUTOFILL_EVENT_CLOSE, OHOS::NWeb::NWebAutofillEvent::CLOSE},
};
std::string GetWebDebugBackGroundColor()
{
return OHOS::system::GetParameter("web.debug.surfaceNodeBackgroundColor", "");
}
} // namespace
constexpr int32_t SINGLE_CLICK_NUM = 1;
@ -1933,7 +1938,10 @@ bool WebPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, co
drawSizeCache_ = drawSize_;
auto offset = Offset(GetCoordinatePoint()->GetX(), GetCoordinatePoint()->GetY());
if (!CheckSafeAreaIsExpand()) {
TAG_LOGD(AceLogTag::ACE_WEB, "Not safe area, drawsize_ : %{public}s", drawSize_.ToString().c_str());
TAG_LOGI(AceLogTag::ACE_WEB, "Not safe area, drawsize_ : %{public}s, web id : %{public}d",
drawSize_.ToString().c_str(), GetWebId());
ACE_SCOPED_TRACE("WebPattern::OnDirtyLayoutWrapperSwap, drawsize_ : %s, web id : %d",
drawSize_.ToString().c_str(), GetWebId());
delegate_->SetBoundsOrResize(drawSize_, offset, isKeyboardInSafeArea_);
IsNeedResizeVisibleViewport();
isKeyboardInSafeArea_ = false;
@ -2961,7 +2969,8 @@ void WebPattern::UpdateWebLayoutSize(int32_t width, int32_t height, bool isKeybo
auto offset = Offset(GetCoordinatePoint()->GetX(), GetCoordinatePoint()->GetY());
// Scroll focused node into view when keyboard show.
TAG_LOGD(AceLogTag::ACE_WEB, "UpdateWebLayoutSize drawsize_ : %{public}s", drawSize_.ToString().c_str());
TAG_LOGI(AceLogTag::ACE_WEB, "UpdateWebLayoutSize drawsize_ : %{public}s, web id : %{public}d",
drawSize_.ToString().c_str(), GetWebId());
delegate_->SetBoundsOrResize(drawSize_, offset, isKeyboard);
delegate_->ResizeVisibleViewport(visibleViewportSize_, isKeyboard);
@ -5166,13 +5175,24 @@ void WebPattern::OnVisibleAreaChange(bool isVisible)
void WebPattern::UpdateBackgroundColorRightNow(int32_t color)
{
Color bkColor = Color(static_cast<uint32_t>(color));
std::string debugBkgroundColor = GetWebDebugBackGroundColor();
if (debugBkgroundColor != "none") {
// debugBkgroundColor : #FFFFFFFF ARGB format
bkColor = Color::ColorFromString(debugBkgroundColor);
TAG_LOGI(AceLogTag::ACE_WEB, "WebPattern::UpdateBackgroundColorRightNow, use debug background color," \
" color=%{public}s, web id = %{public}d", bkColor.ToString().c_str(), GetWebId());
}
TAG_LOGI(AceLogTag::ACE_WEB, "WebPattern::UpdateBackgroundColorRightNow, color=%{public}s, web id = %{public}d",
bkColor.ToString().c_str(), GetWebId());
auto host = GetHost();
CHECK_NULL_VOID(host);
auto renderContext = host->GetRenderContext();
CHECK_NULL_VOID(renderContext);
renderContext->UpdateBackgroundColor(Color(static_cast<uint32_t>(color)));
renderContext->UpdateBackgroundColor(bkColor);
CHECK_NULL_VOID(renderContextForSurface_);
renderContextForSurface_->UpdateBackgroundColor(Color(static_cast<uint32_t>(color)));
renderContextForSurface_->UpdateBackgroundColor(bkColor);
}
Color WebPattern::GetSystemColor() const

View File

@ -319,7 +319,9 @@ bool RosenRenderSurface::CompareBufferSize(int32_t width, int32_t height,
int32_t bufferWidth = surfaceNode->buffer_->GetSurfaceBufferWidth();
int32_t bufferHeight = surfaceNode->buffer_->GetSurfaceBufferHeight();
auto pipeline = AceType::DynamicCast<NG::PipelineContext>(PipelineBase::GetCurrentContext());
CHECK_NULL_RETURN(pipeline, true);
ACE_SCOPED_TRACE("Web CompareBufferSize (width %d, height %d, bufferWidth %d, bufferHeight %d)" \
" pipeline freeze status = %d", width, height, bufferWidth, bufferHeight, pipeline->IsFreezeFlushMessage());
if (bufferWidth > SIZE_LIMIT || bufferHeight > SIZE_LIMIT
|| (abs(height - bufferHeight) < PERMITTED_DIFFERENCE && abs(width - bufferWidth) < PERMITTED_DIFFERENCE)) {
failTimes_ = 0;
@ -373,6 +375,9 @@ void RosenRenderSurface::ConsumeWebBuffer()
}
LOGD("ConsumeWebBuffer x : %{public}f, y : %{public}f, width : %{public}d, height : %{public}d",
orgin_.GetX(), orgin_.GetY(), bufferWidth, bufferHeight);
ACE_SCOPED_TRACE("RosenRenderSurface::ConsumeWebBuffer, bufferWidth %d, bufferHeight %d, orign_x %f, orign_y %f",
bufferWidth, bufferHeight, orgin_.GetX(), orgin_.GetY());
std::shared_ptr<SurfaceBufferNode> surfaceNode = nullptr;
{
std::lock_guard<std::mutex> lock(surfaceNodeMutex_);