Skip to content

Commit

Permalink
Revert "[MacOS] New feature to adjust the backgrounded state of the G…
Browse files Browse the repository at this point in the history
…PU process"

This reverts commit 246a72c.

Reason for revert: Speculative revert, suspected as cause of WebAppIntegration failures on multiple Mac bots, eg https://ci.chromium.org/ui/p/chromium/builders/ci/Mac10.14%20Tests/31178/blamelist

Original change's description:
> [MacOS] New feature to adjust the backgrounded state of the GPU process
>
> The new feature (named "AdjustGpuProcessPriority") ensures the
> backgrounded state of the GPU process mirrors the backgrounded state
> of the browser process.
>
> Bug: 1400472
> Change-Id: I284c21ef27536abe3548aa1338e1464e25ddde89
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4085787
> Commit-Queue: Patrick Monette <pmonette@chromium.org>
> Reviewed-by: Bo Liu <boliu@chromium.org>
> Reviewed-by: Kenneth Russell <kbr@chromium.org>
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1100196}

Bug: 1400472
Change-Id: Ib60528cd0900e46b89c58cac0b083133026f5ff5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4216751
Reviewed-by: Meredith Lane <meredithl@chromium.org>
Auto-Submit: Meredith Lane <meredithl@chromium.org>
Owners-Override: Meredith Lane <meredithl@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Meredith Lane <meredithl@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100268}
  • Loading branch information
Meredith Lane authored and Chromium LUCI CQ committed Feb 2, 2023
1 parent b843212 commit 55cd159
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 482 deletions.
71 changes: 22 additions & 49 deletions base/process/process_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,15 @@
#include "base/feature_list.h"
#include "base/mac/mach_logging.h"
#include "base/memory/free_deleter.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

namespace base {

namespace {

// Enables setting the task role of every child process to
// TASK_DEFAULT_APPLICATION.
BASE_FEATURE(kMacSetDefaultTaskRole,
"MacSetDefaultTaskRole",
FEATURE_DISABLED_BY_DEFAULT);

// Returns the `task_role_t` of the process whose process ID is `pid`.
absl::optional<task_role_t> GetTaskCategoryPolicyRole(
PortProvider* port_provider,
ProcessId pid) {
if (port_provider == nullptr) {
return absl::nullopt;
}

mach_port_t task_port = port_provider->TaskForPid(pid);
if (task_port == TASK_NULL) {
return absl::nullopt;
}

task_category_policy_data_t category_policy;
mach_msg_type_number_t task_info_count = TASK_CATEGORY_POLICY_COUNT;
boolean_t get_default = FALSE;

kern_return_t result =
task_policy_get(task_port, TASK_CATEGORY_POLICY,
reinterpret_cast<task_policy_t>(&category_policy),
&task_info_count, &get_default);
if (result != KERN_SUCCESS) {
MACH_LOG(ERROR, result) << "task_policy_get TASK_CATEGORY_POLICY";
return absl::nullopt;
}
DCHECK(!get_default);
return category_policy.role;
}

} // namespace

Time Process::CreationTime() const {
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, Pid()};
size_t len = 0;
Expand All @@ -80,13 +46,28 @@ bool Process::CanBackgroundProcesses() {

bool Process::IsProcessBackgrounded(PortProvider* port_provider) const {
DCHECK(IsValid());
if (port_provider == nullptr)
return false;

// A process is backgrounded if the role is explicitly
// TASK_BACKGROUND_APPLICATION (as opposed to not being
// TASK_FOREGROUND_APPLICATION).
absl::optional<task_role_t> task_role =
GetTaskCategoryPolicyRole(port_provider, Pid());
return task_role && *task_role == TASK_BACKGROUND_APPLICATION;
mach_port_t task_port = port_provider->TaskForPid(Pid());
if (task_port == TASK_NULL)
return false;

task_category_policy_data_t category_policy;
mach_msg_type_number_t task_info_count = TASK_CATEGORY_POLICY_COUNT;
boolean_t get_default = FALSE;

kern_return_t result =
task_policy_get(task_port, TASK_CATEGORY_POLICY,
reinterpret_cast<task_policy_t>(&category_policy),
&task_info_count, &get_default);
MACH_LOG_IF(ERROR, result != KERN_SUCCESS, result)
<< "task_policy_get TASK_CATEGORY_POLICY";

if (result == KERN_SUCCESS && get_default == FALSE) {
return category_policy.role == TASK_BACKGROUND_APPLICATION;
}
return false;
}

bool Process::SetProcessBackgrounded(PortProvider* port_provider,
Expand All @@ -99,16 +80,8 @@ bool Process::SetProcessBackgrounded(PortProvider* port_provider,
if (task_port == TASK_NULL)
return false;

absl::optional<task_role_t> current_role =
GetTaskCategoryPolicyRole(port_provider, Pid());
if (!current_role) {
return false;
}

if ((background && *current_role == TASK_BACKGROUND_APPLICATION) ||
(!background && *current_role == TASK_FOREGROUND_APPLICATION)) {
if (IsProcessBackgrounded(port_provider) == background)
return true;
}

task_category_policy category_policy;
category_policy.role =
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion chrome/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9956,7 +9956,6 @@ if (!is_android) {
"../browser/focus_ring_browsertest_mac.h",
"../browser/focus_ring_browsertest_mac.mm",
"../browser/global_keyboard_shortcuts_mac_browsertest.mm",
"../browser/gpu/browser_child_process_backgrounded_bridge_interactive_uitest.mm",
"../browser/notifications/notification_interactive_uitest_mac.mm",
"../browser/spellchecker/spellcheck_mac_view_interactive_uitest.mm",
"../browser/ui/cocoa/apps/quit_with_apps_controller_mac_interactive_uitest.mm",
Expand Down
2 changes: 0 additions & 2 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2536,8 +2536,6 @@ source_set("browser") {
"devtools/protocol/native_input_event_builder_mac.mm",
"font_access/font_enumeration_data_source_mac.h",
"font_access/font_enumeration_data_source_mac.mm",
"gpu/browser_child_process_backgrounded_bridge.h",
"gpu/browser_child_process_backgrounded_bridge.mm",
"gpu/ca_transaction_gpu_coordinator.cc",
"gpu/ca_transaction_gpu_coordinator.h",
"media/desktop_media_window_registry_mac.mm",
Expand Down
8 changes: 0 additions & 8 deletions content/browser/browser_child_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,6 @@ void BrowserChildProcessHostImpl::HistogramBadMessageTerminated(
PROCESS_TYPE_MAX);
}

#if !BUILDFLAG(IS_ANDROID)
void BrowserChildProcessHostImpl::SetProcessBackgrounded(bool is_background) {
DCHECK(child_process_);
DCHECK(!child_process_->IsStarting());
child_process_->SetProcessBackgrounded(is_background);
}
#endif // !BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(IS_ANDROID)
void BrowserChildProcessHostImpl::EnableWarmUpConnection() {
can_use_warm_up_connection_ = true;
Expand Down
4 changes: 0 additions & 4 deletions content/browser/browser_child_process_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ class BrowserChildProcessHostImpl

static void HistogramBadMessageTerminated(ProcessType process_type);

#if !BUILDFLAG(IS_ANDROID)
void SetProcessBackgrounded(bool is_background);
#endif // !BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(IS_ANDROID)
void EnableWarmUpConnection();
void DumpProcessStack();
Expand Down
51 changes: 0 additions & 51 deletions content/browser/gpu/browser_child_process_backgrounded_bridge.h

This file was deleted.

Loading

0 comments on commit 55cd159

Please sign in to comment.