OT integration code DocumentPolicyIncludeJSCallStacksInCrashReports
This CL implements the necessary code changes to integrate the origin trial feature for including JavaScript call stacks in crash reports. The collection process is now contingent upon the check within the execution context. The generated Feature can be enabled/disabled by the user or by field trial, and the overridden state takes precedence over the origin trial. combinations: Document doesn't have OT token --> feature is disabled Doc doesn't have OT token, and we provide --enable-features=DocumentPolicyIncludeJSCallStacksInCrashReports --> feature is enabled Doc does not have OT token, and we provide --enable-experimental-web-platform-features --> feature is enabled Doc has OT token --> feature is enabled. Doc has OT token, and we provide --disable-features=DocumentPolicyIncludeJSCallStacksInCrashReports --> feature is disabled Bug: 40268201 Change-Id: Iaef0c18b7db23cc884acf379bb6c74cecd464492 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5491178 Reviewed-by: Ian Clelland <iclelland@chromium.org> Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Commit-Queue: Issack John <issackjohn@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1299596}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
394dac3409
commit
5ab2f29a86
content
third_party/blink
public
mojom
use_counter
metrics
renderer
controller
core
permissions_policy
platform
tools/metrics/histograms
@ -14264,6 +14264,20 @@ void RenderFrameHostImpl::OnSameDocumentCommitProcessed(
|
||||
same_document_navigation_requests_.erase(navigation_token);
|
||||
}
|
||||
|
||||
bool IsDocumentPolicyIncludeJSCallStacksInCrashReportsEnabled(
|
||||
content::RenderFrameHost* rfh) {
|
||||
if (std::optional<bool> state = base::FeatureList::GetStateIfOverridden(
|
||||
blink::features::kDocumentPolicyIncludeJSCallStacksInCrashReports);
|
||||
state.has_value()) {
|
||||
return state.value();
|
||||
}
|
||||
content::RuntimeFeatureStateDocumentData* document_data =
|
||||
content::RuntimeFeatureStateDocumentData::GetForCurrentDocument(rfh);
|
||||
CHECK(document_data);
|
||||
return document_data->runtime_feature_state_read_context()
|
||||
.IsDocumentPolicyIncludeJSCallStacksInCrashReportsEnabled();
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::MaybeGenerateCrashReport(
|
||||
base::TerminationStatus status,
|
||||
int exit_code) {
|
||||
@ -14311,9 +14325,8 @@ void RenderFrameHostImpl::MaybeGenerateCrashReport(
|
||||
if (!reason.empty()) {
|
||||
body.Set("reason", reason);
|
||||
if (reason == "unresponsive" &&
|
||||
base::FeatureList::IsEnabled(
|
||||
blink::features::
|
||||
kDocumentPolicyIncludeJSCallStacksInCrashReports)) {
|
||||
IsDocumentPolicyIncludeJSCallStacksInCrashReportsEnabled(
|
||||
FromFrameToken(GetProcess()->GetID(), GetFrameToken()))) {
|
||||
RenderProcessHostImpl* rph =
|
||||
static_cast<RenderProcessHostImpl*>(GetProcess());
|
||||
const std::string& unresponsive_document_javascript_call_stack =
|
||||
|
@ -380,7 +380,8 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
|
||||
kSetOnlyIfOverridden},
|
||||
{"DocumentPolicyIncludeJSCallStacksInCrashReports",
|
||||
raw_ref(blink::features::
|
||||
kDocumentPolicyIncludeJSCallStacksInCrashReports)},
|
||||
kDocumentPolicyIncludeJSCallStacksInCrashReports),
|
||||
kSetOnlyIfOverridden},
|
||||
{"FencedFramesLocalUnpartitionedDataAccess",
|
||||
raw_ref(blink::features::kFencedFramesLocalUnpartitionedDataAccess)},
|
||||
{"Fledge", raw_ref(blink::features::kFledge), kSetOnlyIfOverridden},
|
||||
|
@ -4365,6 +4365,9 @@ enum WebFeature {
|
||||
kCanvas2DMesh = 4969,
|
||||
kCaretPositionFromPoint = 4970,
|
||||
|
||||
kDocumentPolicyIncludeJSCallStacksInCrashReports = 4971,
|
||||
|
||||
|
||||
// Add new features immediately above this line. Don't change assigned
|
||||
// numbers of any item, and don't reuse removed slots.
|
||||
// Also, run update_use_counter_feature_enum.py in
|
||||
|
@ -278,8 +278,6 @@ void BlinkInitializer::RegisterInterfaces(mojo::BinderMap& binders) {
|
||||
CrossThreadBindRepeating(&V8DetailedMemoryReporterImpl::Bind)),
|
||||
main_thread_task_runner);
|
||||
|
||||
if (RuntimeEnabledFeatures::
|
||||
DocumentPolicyIncludeJSCallStacksInCrashReportsEnabled()) {
|
||||
DCHECK(Platform::Current());
|
||||
// We need to use the IO task runner here because the call stack generator
|
||||
// should work even when the main thread is blocked.
|
||||
@ -287,7 +285,6 @@ void BlinkInitializer::RegisterInterfaces(mojo::BinderMap& binders) {
|
||||
ConvertToBaseRepeatingCallback(
|
||||
CrossThreadBindRepeating(&JavaScriptCallStackGenerator::Bind)),
|
||||
Platform::Current()->GetIOTaskRunner());
|
||||
}
|
||||
}
|
||||
|
||||
void BlinkInitializer::RegisterMemoryWatchers(Platform* platform) {
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "third_party/blink/renderer/core/frame/local_frame.h"
|
||||
#include "third_party/blink/renderer/platform/bindings/dom_wrapper_world.h"
|
||||
#include "third_party/blink/renderer/platform/bindings/script_state.h"
|
||||
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
|
||||
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
|
||||
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
|
||||
#include "third_party/blink/renderer/platform/scheduler/public/main_thread_scheduler.h"
|
||||
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
|
||||
@ -79,6 +81,12 @@ void GenerateJavaScriptCallStack(v8::Isolate* isolate, void* data) {
|
||||
return;
|
||||
}
|
||||
ExecutionContext* execution_context = ToExecutionContext(script_state);
|
||||
if (!RuntimeEnabledFeatures::
|
||||
DocumentPolicyIncludeJSCallStacksInCrashReportsEnabled(
|
||||
execution_context)) {
|
||||
PostHandleCollectedCallStackTask(collector, builder);
|
||||
return;
|
||||
}
|
||||
DOMWrapperWorld& world = script_state->World();
|
||||
auto* execution_dom_window = DynamicTo<LocalDOMWindow>(execution_context);
|
||||
LocalFrame* frame =
|
||||
@ -94,6 +102,9 @@ void GenerateJavaScriptCallStack(v8::Isolate* isolate, void* data) {
|
||||
"Website owner has not opted in for JS call stacks in crash "
|
||||
"reports.");
|
||||
} else {
|
||||
UseCounter::Count(
|
||||
execution_context,
|
||||
WebFeature::kDocumentPolicyIncludeJSCallStacksInCrashReports);
|
||||
FormatStackTrace(isolate, builder);
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ void JavaScriptCallStackGenerator::OnCollectorFinished(
|
||||
|
||||
void JavaScriptCallStackGenerator::CollectJavaScriptCallStack(
|
||||
CollectJavaScriptCallStackCallback callback) {
|
||||
if (RuntimeEnabledFeatures::
|
||||
DocumentPolicyIncludeJSCallStacksInCrashReportsEnabled()) {
|
||||
std::unique_ptr<JavaScriptCallStackCollector> call_stack_collector =
|
||||
std::make_unique<JavaScriptCallStackCollector>(
|
||||
std::move(callback),
|
||||
@ -37,7 +35,6 @@ void JavaScriptCallStackGenerator::CollectJavaScriptCallStack(
|
||||
JavaScriptCallStackCollector* raw_collector = call_stack_collector.get();
|
||||
collectors_.Set(raw_collector, std::move(call_stack_collector));
|
||||
raw_collector->CollectJavaScriptCallStack();
|
||||
}
|
||||
}
|
||||
|
||||
void JavaScriptCallStackGenerator::Bind(
|
||||
|
@ -147,7 +147,6 @@
|
||||
document_policy_name: "include-js-call-stacks-in-crash-reports",
|
||||
value_type: "Bool",
|
||||
default_value: "false",
|
||||
depends_on: ["DocumentPolicyIncludeJSCallStacksInCrashReports"],
|
||||
}
|
||||
],
|
||||
}
|
||||
|
@ -1345,7 +1345,11 @@
|
||||
// IncludeJSCallStacksInCrashReports. https://chromestatus.com/feature/4731248572628992
|
||||
{
|
||||
name: "DocumentPolicyIncludeJSCallStacksInCrashReports",
|
||||
origin_trial_feature_name: "DocumentPolicyIncludeJSCallStacksInCrashReports",
|
||||
status: "experimental",
|
||||
base_feature_status: "enabled",
|
||||
browser_process_read_access: true,
|
||||
copied_from_base_feature_if: "overridden",
|
||||
},
|
||||
{
|
||||
name: "DocumentPolicyNegotiation",
|
||||
|
@ -11543,6 +11543,7 @@ Called by update_use_counter_feature_enum.py.-->
|
||||
<int value="4968" label="HTMLInputInSelect"/>
|
||||
<int value="4969" label="Canvas2DMesh"/>
|
||||
<int value="4970" label="CaretPositionFromPoint"/>
|
||||
<int value="4971" label="DocumentPolicyIncludeJSCallStacksInCrashReports"/>
|
||||
</enum>
|
||||
|
||||
<enum name="FeaturePolicyFeature">
|
||||
|
Reference in New Issue
Block a user