Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restore flag that allowed websockets to not be backgrounded #39754

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions patches/chromium/.patches
Expand Up @@ -131,3 +131,4 @@ potential_fix_for_flaky_desktopcaptureapitest_delegation_unittest.patch
fix_select_the_first_menu_item_when_opened_via_keyboard.patch
chore_add_buildflag_guard_around_new_include.patch
fix_use_delegated_generic_capturer_when_available.patch
revert_remove_the_allowaggressivethrottlingwithwebsocket_feature.patch
@@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <samuel.r.attard@gmail.com>
Date: Tue, 5 Sep 2023 13:22:31 -0700
Subject: Revert "Remove the AllowAggressiveThrottlingWithWebSocket feature."

This reverts commit 615c1810a187840ffeb04096087efff86edb37de.

diff --git a/third_party/blink/renderer/modules/websockets/websocket_channel_impl.cc b/third_party/blink/renderer/modules/websockets/websocket_channel_impl.cc
index 98a78f1a7b6a5005f7d5da4ac279e38b61fac4dc..330e1e37b2d9f154ccc360d1102375efded12ff9 100644
--- a/third_party/blink/renderer/modules/websockets/websocket_channel_impl.cc
+++ b/third_party/blink/renderer/modules/websockets/websocket_channel_impl.cc
@@ -94,6 +94,17 @@ enum WebSocketOpCode {
kOpCodeBinary = 0x2,
};

+// When enabled, a page can be aggressively throttled even if it uses a
+// WebSocket. Aggressive throttling does not affect the execution of WebSocket
+// event handlers, so there is little reason to disable it on pages using a
+// WebSocket.
+//
+// TODO(crbug.com/1121725): Cleanup this feature in June 2021, when it becomes
+// enabled by default on Stable.
+BASE_FEATURE(kAllowAggressiveThrottlingWithWebSocket,
+ "AllowAggressiveThrottlingWithWebSocket",
+ base::FEATURE_ENABLED_BY_DEFAULT);
+
} // namespace

void WebSocketChannelImpl::MessageDataDeleter::operator()(char* p) const {
@@ -284,7 +295,10 @@ bool WebSocketChannelImpl::Connect(const KURL& url, const String& protocol) {
// even if the `WebSocketChannel` is closed.
feature_handle_for_scheduler_ = scheduler->RegisterFeature(
SchedulingPolicy::Feature::kWebSocket,
- SchedulingPolicy{SchedulingPolicy::DisableBackForwardCache()});
+ base::FeatureList::IsEnabled(kAllowAggressiveThrottlingWithWebSocket)
+ ? SchedulingPolicy{SchedulingPolicy::DisableBackForwardCache()}
+ : SchedulingPolicy{SchedulingPolicy::DisableAggressiveThrottling(),
+ SchedulingPolicy::DisableBackForwardCache()});
scheduler->RegisterStickyFeature(
SchedulingPolicy::Feature::kWebSocketSticky,
SchedulingPolicy{SchedulingPolicy::DisableBackForwardCache()});