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

Pipeline to generate and apply whistium patches #7498

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions mandelboxes/browsers/whistium/apply_patches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

WHISTIUM_INSTANCE_IP=$1
WHISTIUM_INSTANCE_SSH_KEY=$2
WHISTIUM_INSTANCE_CHROMIUM_PATH=$3
MONOREPO_PATH=$(git rev-parse --show-toplevel)

# Apply patches
echo "Applying patches..."
PATCH_FOLDER=$MONOREPO_PATH/mandelboxes/browsers/whistium/patches
for filename in $(ls $PATCH_FOLDER) ; do
echo $filename
scp -i $WHISTIUM_INSTANCE_SSH_KEY $PATCH_FOLDER/$filename ubuntu@$WHISTIUM_INSTANCE_IP:/tmp/patch
ssh -i $WHISTIUM_INSTANCE_SSH_KEY ubuntu@$WHISTIUM_INSTANCE_IP "cd $WHISTIUM_INSTANCE_CHROMIUM_PATH && git apply /tmp/patch"
done

echo "-------"

# Copy added files
echo "Adding files..."
ADDED_FOLDER=$MONOREPO_PATH/mandelboxes/browsers/whistium/custom_files
for filename in $(ls $ADDED_FOLDER) ; do
echo $filename
CHROMIUM_REPO_FILEPATH=$(echo $filename | tr "-" "/")
CHROMIUM_REPO_DIRPATH="$(dirname $CHROMIUM_REPO_FILEPATH)"
ssh -i $WHISTIUM_INSTANCE_SSH_KEY ubuntu@$WHISTIUM_INSTANCE_IP "mkdir -p $WHISTIUM_INSTANCE_CHROMIUM_PATH/$CHROMIUM_REPO_DIRPATH"
scp -i $WHISTIUM_INSTANCE_SSH_KEY $ADDED_FOLDER/$filename ubuntu@$WHISTIUM_INSTANCE_IP:$WHISTIUM_INSTANCE_CHROMIUM_PATH/$CHROMIUM_REPO_FILEPATH
done
800 changes: 0 additions & 800 deletions mandelboxes/browsers/whistium/chromium.patch

This file was deleted.

34 changes: 34 additions & 0 deletions mandelboxes/browsers/whistium/generate_patches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

WHISTIUM_INSTANCE_IP=$1
WHISTIUM_INSTANCE_SSH_KEY=$2
WHISTIUM_INSTANCE_CHROMIUM_PATH=$3
MONOREPO_PATH=$(git rev-parse --show-toplevel)

# Create patches for modified files
echo "Creating patch files..."
PATCH_FOLDER=$MONOREPO_PATH/mandelboxes/browsers/whistium/patches
if [ ! -d $PATCH_FOLDER ]; then
mkdir -p $PATCH_FOLDER
fi
for filepath in $(ssh -i $WHISTIUM_INSTANCE_SSH_KEY ubuntu@$WHISTIUM_INSTANCE_IP "cd $WHISTIUM_INSTANCE_CHROMIUM_PATH && git diff --name-only") ; do
PATCH_FILENAME=$(echo $filepath | tr "/" "-")
PATCH_FILENAME=${PATCH_FILENAME%.*}.patch
echo $PATCH_FILENAME
ssh -i $WHISTIUM_INSTANCE_SSH_KEY ubuntu@$WHISTIUM_INSTANCE_IP "cd $WHISTIUM_INSTANCE_CHROMIUM_PATH && git diff $filepath" > $PATCH_FOLDER/$PATCH_FILENAME
done

echo "-------"

# Copy added files
echo "Copying added files..."
ADDED_FOLDER=$MONOREPO_PATH/mandelboxes/browsers/whistium/custom_files
if [ ! -d $ADDED_FOLDER ]; then
mkdir -p $ADDED_FOLDER
fi
for filepath in $(ssh -i $WHISTIUM_INSTANCE_SSH_KEY ubuntu@$WHISTIUM_INSTANCE_IP "cd $WHISTIUM_INSTANCE_CHROMIUM_PATH && git status --porcelain -uall | awk 'match(\$1, \"\\\\?\\\\?\"){print \$2}'") ; do
ADDED_FILENAME=$(echo $filepath | tr "/" "-")
# cp $CHROMIUM_PATH/$filepath $ADDED_FOLDER/$ADDED_FILENAME
scp -i $WHISTIUM_INSTANCE_SSH_KEY ubuntu@$WHISTIUM_INSTANCE_IP:$WHISTIUM_INSTANCE_CHROMIUM_PATH/$filepath $ADDED_FOLDER/$ADDED_FILENAME
echo "---copied as $ADDED_FILENAME"
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc
index a945456d4d15f..14b43c5bb4fd8 100644
--- a/chrome/browser/devtools/devtools_window.cc
+++ b/chrome/browser/devtools/devtools_window.cc
@@ -1090,10 +1090,12 @@ DevToolsWindow::DevToolsWindow(FrontendType frontend_type,
// static
bool DevToolsWindow::AllowDevToolsFor(Profile* profile,
content::WebContents* web_contents) {
+ /* We want DevTools UI in kiosk mode on Whist
// Don't allow DevTools UI in kiosk mode, because the DevTools UI would be
// broken there. See https://crbug.com/514551 for context.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
return false;
+ */

return ChromeDevToolsManagerDelegate::AllowInspection(profile, web_contents);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
index e6efbf1e457ae..aba8b15bec745 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -1366,14 +1366,6 @@ void RenderViewContextMenu::AppendLinkItems() {
AppendProtocolHandlerSubMenu();
}

- // Links to system web app can't be opened in incognito / off-the-record.
- if (!link_system_app_type) {
- menu_model_.AddItemWithStringId(
- IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD,
- in_app ? IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD_INAPP
- : IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD);
- }
-
AppendOpenInWebAppLinkItems();
AppendOpenWithLinkItems();

@@ -1755,6 +1747,10 @@ void RenderViewContextMenu::AppendExitFullscreenItem() {
if (!browser)
return;

+ // If kiosk mode, Whist has enabled the context menu so we must remove this option.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
+ return;
+
// Only show item if in fullscreen mode.
if (!browser->exclusive_access_manager()
->fullscreen_controller()
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc
index 116e2b842fcb7..238fa1cb005c6 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc
@@ -81,9 +81,6 @@ void BookmarkContextMenu::InstallPreRunCallback(base::OnceClosure callback) {

void BookmarkContextMenu::RunMenuAt(const gfx::Point& point,
ui::MenuSourceType source_type) {
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
- return;
-
if (!PreRunCallback().is_null())
std::move(PreRunCallback()).Run();

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/chrome/browser/ui/views/page_action/zoom_view.cc b/chrome/browser/ui/views/page_action/zoom_view.cc
index fba0a8ce686d1..a256348e4ce9f 100644
--- a/chrome/browser/ui/views/page_action/zoom_view.cc
+++ b/chrome/browser/ui/views/page_action/zoom_view.cc
@@ -34,6 +34,9 @@ void ZoomView::UpdateImpl() {
}

bool ZoomView::ShouldBeVisible(bool can_show_bubble) const {
+ // We don't want the server to ever show the zoom bubble view
+ return false;
+ /*
if (delegate()->ShouldHidePageActionIcons())
return false;

@@ -47,6 +50,7 @@ bool ZoomView::ShouldBeVisible(bool can_show_bubble) const {
zoom::ZoomController* zoom_controller =
zoom::ZoomController::FromWebContents(GetWebContents());
return zoom_controller && !zoom_controller->IsAtDefaultZoom();
+ */
}

bool ZoomView::HasAssociatedBubble() const {
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/chrome/browser/ui/views/renderer_context_menu/render_view_context_menu_views.cc b/chrome/browser/ui/views/renderer_context_menu/render_view_context_menu_views.cc
index dd729e8186d03..aeed067f3f4f6 100644
--- a/chrome/browser/ui/views/renderer_context_menu/render_view_context_menu_views.cc
+++ b/chrome/browser/ui/views/renderer_context_menu/render_view_context_menu_views.cc
@@ -362,9 +362,6 @@ void RenderViewContextMenuViews::ExecOpenInReadAnything() {
}

void RenderViewContextMenuViews::Show() {
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
- return;
-
// Menus need a Widget to work. If we're not the active tab we won't
// necessarily be in a widget.
views::Widget* top_level_widget = GetTopLevelWidget();
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index b74b4c2028ccb..1e61c0718d691 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -3281,6 +3281,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kEnableTouchDragDrop,
switches::kEnableUnsafeFastJSCalls,
switches::kEnableUnsafeWebGPU,
+ switches::kEnableGpuCommandStreaming,
switches::kEnableViewport,
switches::kEnableVtune,
switches::kEnableWebGLDeveloperExtensions,
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/gpu/command_buffer/client/client_transfer_cache.cc b/gpu/command_buffer/client/client_transfer_cache.cc
index 00d7a7058340d..3dc5d937f7e25 100644
--- a/gpu/command_buffer/client/client_transfer_cache.cc
+++ b/gpu/command_buffer/client/client_transfer_cache.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "gpu/command_buffer/client/client_transfer_cache.h"
+#include "gpu/command_buffer/client/cmd_buffer_helper.h"

namespace gpu {

@@ -51,12 +52,16 @@ void ClientTransferCache::UnmapAndCreateEntry(uint32_t type, uint32_t id) {

if (mapped_ptr_) {
DCHECK(!transfer_buffer_ptr_);
+ client_->cmd_buffer_helper()->SendBufferToWhist(CommandBufferType::TRANSFER_CACHE,
+ mapped_ptr_->address(), mapped_ptr_->size());
client_->IssueCreateTransferCacheEntry(
type, id, handle.shm_id(), handle.byte_offset(), mapped_ptr_->shm_id(),
mapped_ptr_->offset(), mapped_ptr_->size());
mapped_ptr_ = absl::nullopt;
} else {
DCHECK(!mapped_ptr_);
+ client_->cmd_buffer_helper()->SendBufferToWhist(CommandBufferType::TRANSFER_CACHE,
+ transfer_buffer_ptr_->address(), transfer_buffer_ptr_->size());
client_->IssueCreateTransferCacheEntry(
type, id, handle.shm_id(), handle.byte_offset(),
transfer_buffer_ptr_->shm_id(), transfer_buffer_ptr_->offset(),
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h
index 5d0d6a9a8ed2b..89361a2d3a952 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.h
+++ b/gpu/command_buffer/client/cmd_buffer_helper.h
@@ -17,6 +17,7 @@
#include "base/time/time.h"
#include "base/trace_event/memory_dump_provider.h"
#include "build/build_config.h"
+#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/cmd_buffer_common.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/common/context_result.h"
@@ -35,6 +36,16 @@ const int kPeriodicFlushDelayInMicroseconds = 500;
const int kAutoFlushSmall = 16; // 1/16 of the buffer
const int kAutoFlushBig = 2; // 1/2 of the buffer

+enum class CommandBufferType {
+ GLES,
+ RASTER,
+ WEBGPU,
+ MEM,
+ TRANSFER_CACHE,
+ FONT,
+ FLUSH,
+};
+
// Command buffer helper class. This class simplifies ring buffer management:
// it will allocate the buffer, give it to the buffer interface, and let the
// user add commands to it, while taking care of the synchronization (put and
@@ -204,6 +215,10 @@ class GPU_EXPORT CommandBufferHelper {
if (cmd) {
cmd->Init(token);
}
+ // SetToken command is immediately, so that the corresponding
+ // shared memory buffers can be freed on the client side before
+ // the next shared memory buffer packet is sent from the server.
+ SendCommandsToWhist();
}

void SetBucketSize(uint32_t bucket_id, uint32_t size) {
@@ -215,14 +230,17 @@ class GPU_EXPORT CommandBufferHelper {

void SetBucketData(uint32_t bucket_id,
uint32_t offset,
- uint32_t size,
- uint32_t shared_memory_id,
- uint32_t shared_memory_offset) {
+ ScopedTransferBufferPtr &buffer) {
+ SendBufferToWhist(CommandBufferType::MEM, buffer.address(), buffer.size());
cmd::SetBucketData* cmd = GetCmdSpace<cmd::SetBucketData>();
if (cmd) {
- cmd->Init(bucket_id, offset, size, shared_memory_id,
- shared_memory_offset);
+ cmd->Init(bucket_id, offset, buffer.size(), buffer.shm_id(),
+ buffer.offset());
}
+ // SetBucketData command is sent immediately, to preserve ordering of packets
+ // that depend on the shared memory data. Otherwise the shared memory buffer
+ // sent earlier will get overwritten by some other command's buffer.
+ SendCommandsToWhist();
}

void SetBucketDataImmediate(uint32_t bucket_id,
@@ -290,6 +308,11 @@ class GPU_EXPORT CommandBufferHelper {

int32_t GetPutOffsetForTest() const { return put_; }

+ void SendBufferToWhist(CommandBufferType type, void* buffer, int32_t shm_size);
+ void SendCommandsToWhist();
+
+ virtual CommandBufferType GetCommandBufferType() const = 0;
+
private:
void CalcImmediateEntries(int waiting_count);
bool AllocateRingBuffer();
@@ -348,6 +371,11 @@ class GPU_EXPORT CommandBufferHelper {
// Can be used to track when prior commands have been flushed.
uint32_t flush_generation_ = 0;

+ bool is_renderer_process_ = false;
+ int sock_fd_ = -1;
+ char *socket_buffer = NULL;
+ int32_t last_whist_put_ = 0;
+
friend class CommandBufferHelperTest;
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/gpu/command_buffer/client/gles2_cmd_helper.h b/gpu/command_buffer/client/gles2_cmd_helper.h
index a403753f54999..6e032d3946997 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper.h
@@ -24,6 +24,8 @@ class GPU_GLES2_EXPORT GLES2CmdHelper : public CommandBufferHelper {

~GLES2CmdHelper() override;

+ CommandBufferType GetCommandBufferType() const override;
+
// Include the auto-generated part of this class. We split this because it
// means we can easily edit the non-auto generated parts right here in this
// file instead of having to edit some template or the code generator.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 7c33d18041938..8f6ce21210b08 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -7374,8 +7374,7 @@ bool GLES2Implementation::PackStringsToBucket(GLsizei count,
DCHECK(copy_size + 1 == buffer.size());
reinterpret_cast<char*>(buffer.address())[copy_size] = 0;
}
- helper_->SetBucketData(kResultBucketId, offset, buffer.size(),
- buffer.shm_id(), buffer.offset());
+ helper_->SetBucketData(kResultBucketId, offset, buffer);
offset += buffer.size();
src += buffer.size();
size -= buffer.size();
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/gpu/command_buffer/client/implementation_base.cc b/gpu/command_buffer/client/implementation_base.cc
index 0492f62a9f77e..1414b6bb4350f 100644
--- a/gpu/command_buffer/client/implementation_base.cc
+++ b/gpu/command_buffer/client/implementation_base.cc
@@ -331,8 +331,7 @@ void ImplementationBase::SetBucketContents(uint32_t bucket_id,
}
memcpy(buffer.address(), static_cast<const int8_t*>(data) + offset,
buffer.size());
- helper_->SetBucketData(bucket_id, offset, buffer.size(), buffer.shm_id(),
- buffer.offset());
+ helper_->SetBucketData(bucket_id, offset, buffer);
offset += buffer.size();
size -= buffer.size();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/gpu/command_buffer/client/raster_cmd_helper.h b/gpu/command_buffer/client/raster_cmd_helper.h
index 0dc93d8606b51..cb772dcafde34 100644
--- a/gpu/command_buffer/client/raster_cmd_helper.h
+++ b/gpu/command_buffer/client/raster_cmd_helper.h
@@ -24,6 +24,8 @@ class RASTER_EXPORT RasterCmdHelper : public CommandBufferHelper {

~RasterCmdHelper() override;

+ CommandBufferType GetCommandBufferType() const override;
+
// Include the auto-generated part of this class. We split this because it
// means we can easily edit the non-auto generated parts right here in this
// file instead of having to edit some template or the code generator.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/gpu/command_buffer/client/raster_implementation.h b/gpu/command_buffer/client/raster_implementation.h
index fdd547e776b95..f36db34772074 100644
--- a/gpu/command_buffer/client/raster_implementation.h
+++ b/gpu/command_buffer/client/raster_implementation.h
@@ -276,6 +276,7 @@ class RASTER_EXPORT RasterImplementation : public RasterInterface,
std::unique_ptr<cc::TransferCacheSerializeHelper>
CreateTransferCacheHelperForTesting();
void SetRasterMappedBufferForTesting(ScopedTransferBufferPtr buffer);
+ raw_ptr<RasterCmdHelper> helper_;

private:
class TransferCacheSerializeHelperImpl;
@@ -398,7 +399,6 @@ class RASTER_EXPORT RasterImplementation : public RasterInterface,
void FailGLError(GLenum /* error */) {}
#endif

- raw_ptr<RasterCmdHelper> helper_;
std::string last_error_;
gles2::DebugMarkerManager debug_marker_manager_;
std::string this_in_hex_;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/gpu/command_buffer/client/webgpu_cmd_helper.h b/gpu/command_buffer/client/webgpu_cmd_helper.h
index 5e7ffd1d2230f..f75ea6dbf0b52 100644
--- a/gpu/command_buffer/client/webgpu_cmd_helper.h
+++ b/gpu/command_buffer/client/webgpu_cmd_helper.h
@@ -24,6 +24,8 @@ class WEBGPU_EXPORT WebGPUCmdHelper : public CommandBufferHelper {

~WebGPUCmdHelper() override;

+ CommandBufferType GetCommandBufferType() const override;
+
// Include the auto-generated part of this class. We split this because it
// means we can easily edit the non-auto generated parts right here in this
// file instead of having to edit some template or the code generator.
Loading