|
| 1 | +From 6c1fa2d4d78ea83de486c33a613b58a65bd03bf0 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Sohom <sdatta4@ncsu.edu> |
| 3 | +Date: Wed, 13 Aug 2025 21:08:56 -0400 |
| 4 | +Subject: [PATCH] VisibleV8 for 139 |
| 5 | + |
| 6 | +--- |
| 7 | + .../base/process_launcher/BindService.java | 2 +- |
| 8 | + build/install-build-deps.py | 10 +++- |
| 9 | + chrome/android/java/AndroidManifest.xml | 4 +- |
| 10 | + .../java/gin_java_method_invocation_helper.cc | 2 + |
| 11 | + .../gin_java_function_invocation_helper.cc | 46 ++++++++++++++++++- |
| 12 | + content/renderer/renderer_main.cc | 3 +- |
| 13 | + .../modules/remote_objects/remote_object.cc | 1 + |
| 14 | + .../renderer/platform/bindings/v8_binding.h | 1 + |
| 15 | + 8 files changed, 62 insertions(+), 7 deletions(-) |
| 16 | + |
| 17 | +diff --git a/base/android/java/src/org/chromium/base/process_launcher/BindService.java b/base/android/java/src/org/chromium/base/process_launcher/BindService.java |
| 18 | +index c002b23dbe42e..fa5e777826fee 100644 |
| 19 | +--- a/base/android/java/src/org/chromium/base/process_launcher/BindService.java |
| 20 | ++++ b/base/android/java/src/org/chromium/base/process_launcher/BindService.java |
| 21 | +@@ -30,7 +30,7 @@ final class BindService { |
| 22 | + |
| 23 | + static boolean supportVariableConnections() { |
| 24 | + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q |
| 25 | +- && !BuildConfig.IS_INCREMENTAL_INSTALL; |
| 26 | ++ && !true; // VisibleV8 android change required disabling renderer isolation. |
| 27 | + } |
| 28 | + |
| 29 | + // Note that handler is not guaranteed to be used, and client still need to correctly handle |
| 30 | +diff --git a/build/install-build-deps.py b/build/install-build-deps.py |
| 31 | +index 412962fedf4c8..618b59ea17332 100755 |
| 32 | +--- a/build/install-build-deps.py |
| 33 | ++++ b/build/install-build-deps.py |
| 34 | +@@ -862,8 +862,16 @@ def install_packages(options): |
| 35 | + try: |
| 36 | + packages = find_missing_packages(options) |
| 37 | + if packages: |
| 38 | ++ env = os.environ.copy() |
| 39 | ++ env["LANGUAGE"] = "en" |
| 40 | ++ env["LANG"] = "C" |
| 41 | ++ env["DEBIAN_FRONTEND"] = 'noninteractive' |
| 42 | + quiet = ["-qq", "--assume-yes"] if options.no_prompt else [] |
| 43 | +- subprocess.check_call(["sudo", "apt-get", "install"] + quiet + packages) |
| 44 | ++ if options.no_prompt: |
| 45 | ++ subprocess.check_call(["sudo", "-E", "apt-get", "install"] + quiet + packages, env=env) |
| 46 | ++ else: |
| 47 | ++ subprocess.check_call(["sudo", "apt-get", "install"] + quiet + packages) |
| 48 | ++ |
| 49 | + print(file=sys.stderr) |
| 50 | + else: |
| 51 | + print("No missing packages, and the packages are up to date.", |
| 52 | +diff --git a/chrome/android/java/AndroidManifest.xml b/chrome/android/java/AndroidManifest.xml |
| 53 | +index 40da3e5ffeab7..76e68a1e57845 100644 |
| 54 | +--- a/chrome/android/java/AndroidManifest.xml |
| 55 | ++++ b/chrome/android/java/AndroidManifest.xml |
| 56 | +@@ -1240,13 +1240,13 @@ by a child template that "extends" this file. |
| 57 | + <service android:name="org.chromium.content.app.SandboxedProcessService{{ i }}" |
| 58 | + android:process=":sandboxed_process{{ i }}" |
| 59 | + android:permission="{{ manifest_package }}.permission.CHILD_SERVICE" |
| 60 | +- android:isolatedProcess="true" |
| 61 | ++ android:isolatedProcess="false" |
| 62 | + android:exported="{{sandboxed_service_exported|default(false)}}" |
| 63 | + {% if (i == 0) %} |
| 64 | + android:useAppZygote="true" |
| 65 | + {% endif %} |
| 66 | + {% if (sandboxed_service_exported|default(false)) == 'true' %} |
| 67 | +- android:externalService="true" |
| 68 | ++ android:externalService="false" |
| 69 | + tools:ignore="ExportedService" |
| 70 | + android:visibleToInstantApps="true" |
| 71 | + {% endif %} /> |
| 72 | +diff --git a/content/browser/android/java/gin_java_method_invocation_helper.cc b/content/browser/android/java/gin_java_method_invocation_helper.cc |
| 73 | +index 719faf03919fa..2811c11c26cc0 100644 |
| 74 | +--- a/content/browser/android/java/gin_java_method_invocation_helper.cc |
| 75 | ++++ b/content/browser/android/java/gin_java_method_invocation_helper.cc |
| 76 | +@@ -12,6 +12,8 @@ |
| 77 | + #include "base/android/event_log.h" |
| 78 | + #include "base/android/jni_android.h" |
| 79 | + #include "base/android/jni_string.h" |
| 80 | ++#include "base/logging.h" |
| 81 | ++#include "base/debug/stack_trace.h" |
| 82 | + #include "content/browser/android/java/gin_java_script_to_java_types_coercion.h" |
| 83 | + #include "content/browser/android/java/java_method.h" |
| 84 | + #include "content/common/android/gin_java_bridge_value.h" |
| 85 | +diff --git a/content/renderer/java/gin_java_function_invocation_helper.cc b/content/renderer/java/gin_java_function_invocation_helper.cc |
| 86 | +index 124d40ab0e419..116ff2c0cd221 100644 |
| 87 | +--- a/content/renderer/java/gin_java_function_invocation_helper.cc |
| 88 | ++++ b/content/renderer/java/gin_java_function_invocation_helper.cc |
| 89 | +@@ -14,6 +14,7 @@ |
| 90 | + #include "content/renderer/java/gin_java_bridge_object.h" |
| 91 | + #include "content/renderer/java/gin_java_bridge_value_converter.h" |
| 92 | + #include "v8/include/v8-exception.h" |
| 93 | ++#include "v8/include/v8-visiblev8.h" |
| 94 | + |
| 95 | + namespace content { |
| 96 | + |
| 97 | +@@ -79,6 +80,13 @@ v8::Local<v8::Value> GinJavaFunctionInvocationHelper::Invoke( |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | ++ std::vector<v8::Local<v8::Value>> visv8_args; |
| 102 | ++ |
| 103 | ++ v8::Local<v8::Value> val; |
| 104 | ++ while (args->GetNext(&val)) { |
| 105 | ++ visv8_args.push_back(val); |
| 106 | ++ } |
| 107 | ++ |
| 108 | + mojom::GinJavaBridgeError error = |
| 109 | + mojom::GinJavaBridgeError::kGinJavaBridgeNoError; |
| 110 | + |
| 111 | +@@ -95,12 +103,24 @@ v8::Local<v8::Value> GinJavaFunctionInvocationHelper::Invoke( |
| 112 | + } |
| 113 | + } |
| 114 | + if (!result.get()) { |
| 115 | ++ auto* functionCallbackInfo = args->GetFunctionCallbackInfo(); |
| 116 | ++ v8::visv8_log_java_api_call( |
| 117 | ++ args->isolate(), false, functionCallbackInfo->Data().As<v8::String>(), |
| 118 | ++ functionCallbackInfo->This().As<v8::Object>(), |
| 119 | ++ v8::Undefined(args->isolate()), visv8_args, visv8_args.size()); |
| 120 | + args->isolate()->ThrowException(v8::Exception::Error(gin::StringToV8( |
| 121 | + args->isolate(), base::StrCat({"Error invoking ", method_name_, ": ", |
| 122 | + GinJavaBridgeErrorToString(error)})))); |
| 123 | + return v8::Undefined(args->isolate()); |
| 124 | + } |
| 125 | + if (!result->is_blob()) { |
| 126 | ++ auto* functionCallbackInfo = args->GetFunctionCallbackInfo(); |
| 127 | ++ v8::visv8_log_java_api_call( |
| 128 | ++ args->isolate(), false, functionCallbackInfo->Data().As<v8::String>(), |
| 129 | ++ functionCallbackInfo->This().As<v8::Object>(), |
| 130 | ++ converter_->ToV8Value(result.get(), |
| 131 | ++ args->isolate()->GetCurrentContext()), |
| 132 | ++ visv8_args, visv8_args.size()); |
| 133 | + return converter_->ToV8Value(result.get(), |
| 134 | + args->isolate()->GetCurrentContext()); |
| 135 | + } |
| 136 | +@@ -116,15 +136,39 @@ v8::Local<v8::Value> GinJavaFunctionInvocationHelper::Invoke( |
| 137 | + if (object_result) { |
| 138 | + gin::Handle<GinJavaBridgeObject> controller = |
| 139 | + gin::CreateHandle(args->isolate(), object_result); |
| 140 | +- if (controller.IsEmpty()) |
| 141 | ++ if (controller.IsEmpty()) { |
| 142 | ++ auto* functionCallbackInfo = args->GetFunctionCallbackInfo(); |
| 143 | ++ v8::visv8_log_java_api_call( |
| 144 | ++ args->isolate(), false, |
| 145 | ++ functionCallbackInfo->Data().As<v8::String>(), |
| 146 | ++ functionCallbackInfo->This().As<v8::Object>(), |
| 147 | ++ v8::Undefined(args->isolate()), visv8_args, visv8_args.size()); |
| 148 | + return v8::Undefined(args->isolate()); |
| 149 | ++ } |
| 150 | ++ auto* functionCallbackInfo = args->GetFunctionCallbackInfo(); |
| 151 | ++ v8::visv8_log_java_api_call( |
| 152 | ++ args->isolate(), false, functionCallbackInfo->Data().As<v8::String>(), |
| 153 | ++ functionCallbackInfo->This().As<v8::Object>(), controller.ToV8(), |
| 154 | ++ visv8_args, visv8_args.size()); |
| 155 | + return controller.ToV8(); |
| 156 | + } |
| 157 | + } else if (gin_value->IsType(GinJavaBridgeValue::TYPE_NONFINITE)) { |
| 158 | + float float_value; |
| 159 | + gin_value->GetAsNonFinite(&float_value); |
| 160 | ++ auto* functionCallbackInfo = args->GetFunctionCallbackInfo(); |
| 161 | ++ v8::visv8_log_java_api_call(args->isolate(), false, |
| 162 | ++ functionCallbackInfo->Data().As<v8::String>(), |
| 163 | ++ functionCallbackInfo->This().As<v8::Object>(), |
| 164 | ++ v8::Number::New(args->isolate(), float_value), |
| 165 | ++ visv8_args, visv8_args.size()); |
| 166 | + return v8::Number::New(args->isolate(), float_value); |
| 167 | + } |
| 168 | ++ |
| 169 | ++ auto* functionCallbackInfo = args->GetFunctionCallbackInfo(); |
| 170 | ++ v8::visv8_log_java_api_call( |
| 171 | ++ args->isolate(), false, functionCallbackInfo->Data().As<v8::String>(), |
| 172 | ++ functionCallbackInfo->This().As<v8::Object>(), |
| 173 | ++ v8::Undefined(args->isolate()), visv8_args, visv8_args.size()); |
| 174 | + return v8::Undefined(args->isolate()); |
| 175 | + } |
| 176 | + |
| 177 | +diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc |
| 178 | +index 1613e02e24fab..efa5ef53c422d 100644 |
| 179 | +--- a/content/renderer/renderer_main.cc |
| 180 | ++++ b/content/renderer/renderer_main.cc |
| 181 | +@@ -229,8 +229,7 @@ int RendererMain(MainFunctionParams parameters) { |
| 182 | + { |
| 183 | + content::ContentRendererClient* client = GetContentClient()->renderer(); |
| 184 | + bool should_run_loop = true; |
| 185 | +- bool need_sandbox = |
| 186 | +- !command_line.HasSwitch(sandbox::policy::switches::kNoSandbox); |
| 187 | ++ bool need_sandbox = false; // VisibleV8 disable sandbox for desktop |
| 188 | + |
| 189 | + if (!need_sandbox) { |
| 190 | + // The post-sandbox actions still need to happen at some point. |
| 191 | +diff --git a/third_party/blink/renderer/modules/remote_objects/remote_object.cc b/third_party/blink/renderer/modules/remote_objects/remote_object.cc |
| 192 | +index 596c63d91183e..1e7585231c6a8 100644 |
| 193 | +--- a/third_party/blink/renderer/modules/remote_objects/remote_object.cc |
| 194 | ++++ b/third_party/blink/renderer/modules/remote_objects/remote_object.cc |
| 195 | +@@ -6,6 +6,7 @@ |
| 196 | + |
| 197 | + #include <tuple> |
| 198 | + |
| 199 | ++#include "base/logging.h" |
| 200 | + #include "base/numerics/safe_conversions.h" |
| 201 | + #include "gin/converter.h" |
| 202 | + #include "third_party/blink/public/web/blink.h" |
| 203 | +diff --git a/third_party/blink/renderer/platform/bindings/v8_binding.h b/third_party/blink/renderer/platform/bindings/v8_binding.h |
| 204 | +index 4c7d81cd06492..bd023d9841c10 100644 |
| 205 | +--- a/third_party/blink/renderer/platform/bindings/v8_binding.h |
| 206 | ++++ b/third_party/blink/renderer/platform/bindings/v8_binding.h |
| 207 | +@@ -50,6 +50,7 @@ |
| 208 | + #include "v8/include/v8-maybe.h" |
| 209 | + #include "v8/include/v8-persistent-handle.h" |
| 210 | + #include "v8/include/v8-primitive.h" |
| 211 | ++#include "v8/include/v8-visiblev8.h" |
| 212 | + #include "v8/include/v8-value.h" |
| 213 | + |
| 214 | + namespace blink { |
| 215 | +-- |
| 216 | +2.43.0 |
| 217 | + |
0 commit comments