Avoid running DocumentLoader::StartLoadingResponse during initial commit
DocumentLoader::StartLoadingResponse body can take multiple ms and post a bunch of tasks when initializing the renderer with the initial empty document. This is not necessary, since the document doesn't have anything to load. This change adds a feature to avoid doing this. If the results look promising, I may look into other renderer init improvements. Bug: 332706093 Change-Id: I503f4851ebe722e50a513886512b323e856f481a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5502925 Commit-Queue: Clark DuVall <cduvall@chromium.org> Reviewed-by: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/main@{#1299623}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
62ebb7470c
commit
cfdf565f48
android_webview/java/src/org/chromium/android_webview/common
testing/variations
third_party/blink
@ -995,6 +995,7 @@ public final class ProductionSupportedFlagList {
|
||||
Flag.baseFeature(
|
||||
CcFeatures.METRICS_TRACING_CALCULATION_REDUCTION,
|
||||
"Reduces Renderer event latency attribution to only during tracing."),
|
||||
Flag.baseFeature(BlinkFeatures.STREAMLINE_RENDERER_INIT),
|
||||
// Add new commandline switches and features above. The final entry should have a
|
||||
// trailing comma for cleaner diffs.
|
||||
};
|
||||
|
@ -19261,6 +19261,27 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"StreamlineRendererInit": [
|
||||
{
|
||||
"platforms": [
|
||||
"android",
|
||||
"android_webview",
|
||||
"chromeos",
|
||||
"chromeos_lacros",
|
||||
"linux",
|
||||
"mac",
|
||||
"windows"
|
||||
],
|
||||
"experiments": [
|
||||
{
|
||||
"name": "Enabled",
|
||||
"enable_features": [
|
||||
"StreamlineRendererInit"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"StructuredMetricsExternalMetrics": [
|
||||
{
|
||||
"platforms": [
|
||||
|
5
third_party/blink/common/features.cc
vendored
5
third_party/blink/common/features.cc
vendored
@ -2296,6 +2296,11 @@ BASE_FEATURE(kStopInBackground,
|
||||
#endif
|
||||
);
|
||||
|
||||
// Reduces the work done during renderer initialization.
|
||||
BASE_FEATURE(kStreamlineRendererInit,
|
||||
"StreamlineRendererInit",
|
||||
base::FEATURE_DISABLED_BY_DEFAULT);
|
||||
|
||||
BASE_FEATURE(kStylusPointerAdjustment,
|
||||
"StylusPointerAdjustment",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
|
2
third_party/blink/public/common/features.h
vendored
2
third_party/blink/public/common/features.h
vendored
@ -1518,6 +1518,8 @@ BLINK_COMMON_EXPORT extern const base::FeatureParam<bool>
|
||||
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kStopInBackground);
|
||||
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kStreamlineRendererInit);
|
||||
|
||||
// Stylus gestures for editable web content.
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kStylusRichGestures);
|
||||
// Apply touch adjustment for stylus pointer events. This feature allows
|
||||
|
@ -97,8 +97,11 @@
|
||||
#include "third_party/blink/renderer/core/frame/navigator.h"
|
||||
#include "third_party/blink/renderer/core/frame/settings.h"
|
||||
#include "third_party/blink/renderer/core/frame/web_feature.h"
|
||||
#include "third_party/blink/renderer/core/html/html_body_element.h"
|
||||
#include "third_party/blink/renderer/core/html/html_document.h"
|
||||
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
|
||||
#include "third_party/blink/renderer/core/html/html_head_element.h"
|
||||
#include "third_party/blink/renderer/core/html/html_html_element.h"
|
||||
#include "third_party/blink/renderer/core/html/html_object_element.h"
|
||||
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
|
||||
#include "third_party/blink/renderer/core/html/parser/text_resource_decoder_builder.h"
|
||||
@ -1932,6 +1935,23 @@ void DocumentLoader::StartLoadingResponse() {
|
||||
if (!frame_)
|
||||
return;
|
||||
|
||||
// TODO(crbug.com/332706093): See if this optimization can be enabled for
|
||||
// non-main frames after fixing failing tests.
|
||||
if (base::FeatureList::IsEnabled(features::kStreamlineRendererInit) &&
|
||||
frame_->IsMainFrame() && loading_url_as_empty_document_ &&
|
||||
commit_reason_ == CommitReason::kInitialization) {
|
||||
// We know this is an empty document, so explicitly set empty content
|
||||
// without going through the parser, which has a lot of overhead.
|
||||
Document* document = frame_->GetDocument();
|
||||
auto* html = MakeGarbageCollected<HTMLHtmlElement>(*document);
|
||||
html->AppendChild(MakeGarbageCollected<HTMLHeadElement>(*document));
|
||||
document->AppendChild(html);
|
||||
html->AppendChild(MakeGarbageCollected<HTMLBodyElement>(*document));
|
||||
|
||||
FinishedLoading(base::TimeTicks::Now());
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_GE(state_, kCommitted);
|
||||
|
||||
CreateParserPostCommit();
|
||||
|
Reference in New Issue
Block a user