Commit 678cb604 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

[DevTools] Do not pause worklets on start

Worklets running in a separate thread do not have parent_devtools_token,
and so we don't support debugging them. This should probably be fixed.

Meanwhile, we should not also pause them on start - otherwise there is
no way to unpause because nobody is actually debugging them.

Bug: 901112
Change-Id: I63b59da95a1181ff03886f8fc233aa621726f1f8
Reviewed-on: https://chromium-review.googlesource.com/c/1313837Reviewed-by: default avatarYi Gu <yigu@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605434}
parent b8265a0c
...@@ -84,6 +84,7 @@ WorkerInspectorController::WorkerInspectorController( ...@@ -84,6 +84,7 @@ WorkerInspectorController::WorkerInspectorController(
Platform::Current()->GetIOTaskRunner(); Platform::Current()->GetIOTaskRunner();
if (!parent_devtools_token_.is_empty() && io_task_runner) { if (!parent_devtools_token_.is_empty() && io_task_runner) {
// There may be no io task runner in unit tests. // There may be no io task runner in unit tests.
wait_for_debugger_ = devtools_params->wait_for_debugger;
agent_ = new DevToolsAgent(this, inspected_frames_.Get(), probe_sink_.Get(), agent_ = new DevToolsAgent(this, inspected_frames_.Get(), probe_sink_.Get(),
std::move(inspector_task_runner), std::move(inspector_task_runner),
std::move(io_task_runner)); std::move(io_task_runner));
...@@ -146,6 +147,13 @@ void WorkerInspectorController::FlushProtocolNotifications() { ...@@ -146,6 +147,13 @@ void WorkerInspectorController::FlushProtocolNotifications() {
agent_->FlushProtocolNotifications(); agent_->FlushProtocolNotifications();
} }
void WorkerInspectorController::WaitForDebuggerIfNeeded() {
if (!wait_for_debugger_)
return;
wait_for_debugger_ = false;
debugger_->PauseWorkerOnStart(thread_);
}
void WorkerInspectorController::WillProcessTask( void WorkerInspectorController::WillProcessTask(
const base::PendingTask& pending_task) {} const base::PendingTask& pending_task) {}
......
...@@ -69,6 +69,7 @@ class WorkerInspectorController final ...@@ -69,6 +69,7 @@ class WorkerInspectorController final
DevToolsAgent* GetDevToolsAgent() const { return agent_.Get(); } DevToolsAgent* GetDevToolsAgent() const { return agent_.Get(); }
void Dispose(); void Dispose();
void FlushProtocolNotifications(); void FlushProtocolNotifications();
void WaitForDebuggerIfNeeded();
private: private:
WorkerInspectorController(WorkerThread*, WorkerInspectorController(WorkerThread*,
...@@ -99,6 +100,7 @@ class WorkerInspectorController final ...@@ -99,6 +100,7 @@ class WorkerInspectorController final
Member<InspectedFrames> inspected_frames_; Member<InspectedFrames> inspected_frames_;
Member<CoreProbeSink> probe_sink_; Member<CoreProbeSink> probe_sink_;
int session_count_ = 0; int session_count_ = 0;
bool wait_for_debugger_ = false;
// These fields are set up in the constructor and then read // These fields are set up in the constructor and then read
// on a random thread from EmitTraceEvent(). // on a random thread from EmitTraceEvent().
......
...@@ -435,7 +435,6 @@ void WorkerThread::InitializeOnWorkerThread( ...@@ -435,7 +435,6 @@ void WorkerThread::InitializeOnWorkerThread(
const base::Optional<WorkerBackingThreadStartupData>& thread_startup_data, const base::Optional<WorkerBackingThreadStartupData>& thread_startup_data,
std::unique_ptr<WorkerDevToolsParams> devtools_params) { std::unique_ptr<WorkerDevToolsParams> devtools_params) {
DCHECK(IsCurrentThread()); DCHECK(IsCurrentThread());
bool wait_for_debugger = devtools_params->wait_for_debugger;
{ {
MutexLocker lock(mutex_); MutexLocker lock(mutex_);
DCHECK_EQ(ThreadState::kNotStarted, thread_state_); DCHECK_EQ(ThreadState::kNotStarted, thread_state_);
...@@ -492,11 +491,7 @@ void WorkerThread::InitializeOnWorkerThread( ...@@ -492,11 +491,7 @@ void WorkerThread::InitializeOnWorkerThread(
// Otherwise, InspectorTaskRunner might interrupt isolate execution // Otherwise, InspectorTaskRunner might interrupt isolate execution
// from another thread and try to resume "pause on start" before // from another thread and try to resume "pause on start" before
// we even paused. // we even paused.
if (wait_for_debugger) { worker_inspector_controller_->WaitForDebuggerIfNeeded();
WorkerThreadDebugger* debugger = WorkerThreadDebugger::From(GetIsolate());
if (debugger)
debugger->PauseWorkerOnStart(this);
}
} }
void WorkerThread::EvaluateClassicScriptOnWorkerThread( void WorkerThread::EvaluateClassicScriptOnWorkerThread(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment