Repository navigation
Update generated documentation for config/base.gypi, starboard/stub/c… - #1
Merged
Merged
Conversation
…onfiguration_public.h, and Starboard modules to reflect code changes, including documentation for the new decode_target, image, memory_reporter, microphone, and speech_synthesis modules.
dahlstrom-g
pushed a commit
to dahlstrom-g/cobalt
that referenced
this pull request
May 15, 2023
TBR=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com Change-Id: I1f488c9416d16f90e07eaa65be46be96a9bca307 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2573649 Reviewed-by: v8-ci-autoroll-builder <v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/8.8@{youtube#16} Cr-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{youtube#1} Cr-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094}
dahlstrom-g
pushed a commit
to dahlstrom-g/cobalt
that referenced
this pull request
May 16, 2023
TBR=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com Change-Id: I1f488c9416d16f90e07eaa65be46be96a9bca307 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2573649 Reviewed-by: v8-ci-autoroll-builder <v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/8.8@{youtube#16} Cr-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{youtube#1} Cr-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094} git-subtree-dir: third_party/v8 git-subtree-split: ae6c9f9a8684f703147a14c1eb5eb7417b400fa2
dahlstrom-g
pushed a commit
to dahlstrom-g/cobalt
that referenced
this pull request
Jun 16, 2023
TBR=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com Change-Id: Icacc432e46f8f38ae7dca18175540bad5d4fbd58 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2689678 Reviewed-by: v8-ci-autoroll-builder <v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/8.8@{youtube#35} Cr-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{youtube#1} Cr-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094} git-subtree-dir: third_party/v8 git-subtree-split: f7f4327516912dfca0d7401044e890ca0ce885ad
dahlstrom-g
pushed a commit
to dahlstrom-g/cobalt
that referenced
this pull request
Jun 16, 2023
TBR=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com Change-Id: Icacc432e46f8f38ae7dca18175540bad5d4fbd58 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2689678 Reviewed-by: v8-ci-autoroll-builder <v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/8.8@{youtube#35} Cr-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{youtube#1} Cr-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094} git-subtree-dir: third_party/v8 git-subtree-split: f7f4327516912dfca0d7401044e890ca0ce885ad
dahlstrom-g
pushed a commit
to dahlstrom-g/cobalt
that referenced
this pull request
Jul 20, 2023
TBR=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com Change-Id: I00ea48c106c6ba2e1e0d5a9bbbf762452cff1715 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2822626 Reviewed-by: v8-ci-autoroll-builder <v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/8.9@{youtube#52} Cr-Branched-From: 16b9bbbd581c25391981aa03180b76aa60463a3e-refs/heads/8.9.255@{youtube#1} Cr-Branched-From: d16a2a688498bd1c3e6a49edb25d8c4ca56232dc-refs/heads/master@{#72039} git-subtree-dir: third_party/v8 git-subtree-split: a2d8eca22ad478a95ca67bb2421a9a2535113925
dahlstrom-g
pushed a commit
to dahlstrom-g/cobalt
that referenced
this pull request
Jul 22, 2023
TBR=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com Change-Id: I00ea48c106c6ba2e1e0d5a9bbbf762452cff1715 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2822626 Reviewed-by: v8-ci-autoroll-builder <v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/8.9@{youtube#52} Cr-Branched-From: 16b9bbbd581c25391981aa03180b76aa60463a3e-refs/heads/8.9.255@{youtube#1} Cr-Branched-From: d16a2a688498bd1c3e6a49edb25d8c4ca56232dc-refs/heads/master@{#72039} git-subtree-dir: third_party/v8 git-subtree-split: a2d8eca22ad478a95ca67bb2421a9a2535113925
dahlstrom-g
pushed a commit
that referenced
this pull request
Feb 4, 2024
TBR=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com Change-Id: I054b8a5258c6a5d34e58b1bf1fedfbf7743d42a8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2880138 Reviewed-by: v8-ci-autoroll-builder <v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/9.0@{#58} Cr-Branched-From: bd0108b4c88e0d6f2350cb79b5f363fbd02f3eb7-refs/heads/9.0.257@{#1} Cr-Branched-From: 349bcc6a075411f1a7ce2d866c3dfeefc2efa39d-refs/heads/master@{#73001} git-subtree-dir: third_party/v8 git-subtree-split: 8560c85efde5dc608772b2ecce91952fc4b09f65
dahlstrom-g
pushed a commit
that referenced
this pull request
Nov 12, 2024
Change-Id: I47056e044d5669399c6456f9ac29168f37c7c126 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5996851 Bot-Commit: Chrome Release Bot (LUCI) <chrome-official-brancher@chops-service-accounts.iam.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/6822@{#1} Cr-Branched-From: 5cea56cb0eb7006ee6ad7ffd997926c0fc80a9ca-refs/heads/main@{#1378720}
kjyoun
added a commit
to kjyoun/cobalt
that referenced
this pull request
Jun 24, 2025
johnxwork
added a commit
to johnxwork/cobalt
that referenced
this pull request
Sep 2, 2025
This feature was designed for mobile client and Cobalt should not need it. In addition, the attempt to show the MediaControl overlay is causing the youtube#1 crash in canary. Bug: 427982512
johnxwork
added a commit
to johnxwork/cobalt
that referenced
this pull request
Sep 2, 2025
This feature was designed for mobile client and Cobalt should not need it. In addition, the attempt to show the MediaControl overlay is causing the youtube#1 crash in canary. Bug: 427982512
johnxwork
added a commit
to johnxwork/cobalt
that referenced
this pull request
Sep 2, 2025
This feature was designed for mobile client and Cobalt should not need it. In addition, the attempt to show the MediaControl overlay is causing the youtube#1 crash in canary. Bug: 427982512
Closed
sideb0ard
added a commit
that referenced
this pull request
Jul 7, 2026
…:ThreadPool (#11184) CobaltPerformance memory measurement APIs (MeasureAvailableCpuMemory, MeasureUsedCpuMemory, MeasureUsedSwapMemory, MeasureReservedVirtualMemory) were executing synchronous system metrics queries and file reads on the Renderer thread sequence, causing UI thread stalls of up to 2.37 ms per invocation (11.04 ms total during trace analysis). This change wraps the system queries using base::ThreadPool::PostTaskAndReplyWithResult, ensuring system file reads run on a background thread pool without blocking the main Renderer message loop. ### Quantitative Performance Metrics (Optimization #1) 1. Invocation Frequency & Call Count: • MeasureUsedSwapMemory : Called 3 times during the trace period. • MeasureUsedCpuMemory : Called 2 times. • MeasureAvailableCpuMemory : Called 1 time. • MeasureReservedVirtualMemory : Called 1 time. • Total synchronous calls on Renderer thread sequence: 7 calls. 2. Main Thread Blocking Duration (CPU / IO Stall Savings): • MeasureUsedSwapMemory : 7.11 ms total (avg 2.37 ms per call). • MeasureUsedCpuMemory : 1.91 ms total (avg 0.96 ms per call). • MeasureAvailableCpuMemory : 1.24 ms total (1.24 ms per call). • MeasureReservedVirtualMemory : 0.78 ms total (0.78 ms per call). • Total direct Renderer thread blocking time saved: 11.04 ms (over 7 invocations). 3. Impact Summary for CL Description: • Before Change: Every call to window.performance memory metrics / H5VCC settings triggered synchronous system calls ( /proc file reads & system stats) on the Renderer message loop, blocking JavaScript execution by up to 2.37 ms per invocation (total 11.04 ms stall during the trace). • After Change: Memory metrics are queried off-thread via base::ThreadPool , reducing Chrome_InProcRendererThread blocking time to 0.00 ms for memory measurement API calls. Bug: 530222962
briantting
pushed a commit
that referenced
this pull request
Jul 7, 2026
…memory queries to base::ThreadPool Refer to original PR: #11184 CobaltPerformance memory measurement APIs (MeasureAvailableCpuMemory, MeasureUsedCpuMemory, MeasureUsedSwapMemory, MeasureReservedVirtualMemory) were executing synchronous system metrics queries and file reads on the Renderer thread sequence, causing UI thread stalls of up to 2.37 ms per invocation (11.04 ms total during trace analysis). This change wraps the system queries using base::ThreadPool::PostTaskAndReplyWithResult, ensuring system file reads run on a background thread pool without blocking the main Renderer message loop. ### Quantitative Performance Metrics (Optimization #1) 1. Invocation Frequency & Call Count: • MeasureUsedSwapMemory : Called 3 times during the trace period. • MeasureUsedCpuMemory : Called 2 times. • MeasureAvailableCpuMemory : Called 1 time. • MeasureReservedVirtualMemory : Called 1 time. • Total synchronous calls on Renderer thread sequence: 7 calls. 2. Main Thread Blocking Duration (CPU / IO Stall Savings): • MeasureUsedSwapMemory : 7.11 ms total (avg 2.37 ms per call). • MeasureUsedCpuMemory : 1.91 ms total (avg 0.96 ms per call). • MeasureAvailableCpuMemory : 1.24 ms total (1.24 ms per call). • MeasureReservedVirtualMemory : 0.78 ms total (0.78 ms per call). • Total direct Renderer thread blocking time saved: 11.04 ms (over 7 invocations). 3. Impact Summary for CL Description: • Before Change: Every call to window.performance memory metrics / H5VCC settings triggered synchronous system calls ( /proc file reads & system stats) on the Renderer message loop, blocking JavaScript execution by up to 2.37 ms per invocation (total 11.04 ms stall during the trace). • After Change: Memory metrics are queried off-thread via base::ThreadPool , reducing Chrome_InProcRendererThread blocking time to 0.00 ms for memory measurement API calls. Bug: 530222962 (cherry picked from commit 7f8e586)
briantting
pushed a commit
that referenced
this pull request
Jul 7, 2026
…memory queries to base::ThreadPool Refer to original PR: #11184 CobaltPerformance memory measurement APIs (MeasureAvailableCpuMemory, MeasureUsedCpuMemory, MeasureUsedSwapMemory, MeasureReservedVirtualMemory) were executing synchronous system metrics queries and file reads on the Renderer thread sequence, causing UI thread stalls of up to 2.37 ms per invocation (11.04 ms total during trace analysis). This change wraps the system queries using base::ThreadPool::PostTaskAndReplyWithResult, ensuring system file reads run on a background thread pool without blocking the main Renderer message loop. ### Quantitative Performance Metrics (Optimization #1) 1. Invocation Frequency & Call Count: • MeasureUsedSwapMemory : Called 3 times during the trace period. • MeasureUsedCpuMemory : Called 2 times. • MeasureAvailableCpuMemory : Called 1 time. • MeasureReservedVirtualMemory : Called 1 time. • Total synchronous calls on Renderer thread sequence: 7 calls. 2. Main Thread Blocking Duration (CPU / IO Stall Savings): • MeasureUsedSwapMemory : 7.11 ms total (avg 2.37 ms per call). • MeasureUsedCpuMemory : 1.91 ms total (avg 0.96 ms per call). • MeasureAvailableCpuMemory : 1.24 ms total (1.24 ms per call). • MeasureReservedVirtualMemory : 0.78 ms total (0.78 ms per call). • Total direct Renderer thread blocking time saved: 11.04 ms (over 7 invocations). 3. Impact Summary for CL Description: • Before Change: Every call to window.performance memory metrics / H5VCC settings triggered synchronous system calls ( /proc file reads & system stats) on the Renderer message loop, blocking JavaScript execution by up to 2.37 ms per invocation (total 11.04 ms stall during the trace). • After Change: Memory metrics are queried off-thread via base::ThreadPool , reducing Chrome_InProcRendererThread blocking time to 0.00 ms for memory measurement API calls. Bug: 530222962 (cherry picked from commit 7f8e586)
haozheng-cobalt
added a commit
to haozheng-cobalt/cobalt
that referenced
this pull request
Oct 20, 2026
Improves Cobalt storage UMA telemetry and CDP verification tooling strictly within `cobalt/` to prevent one-time background storage cleanups from polluting startup I/O metrics while capturing post-cleanup disk footprint on Launch youtube#1: 1. 4-Step t=30s "Sandwich" Ordering (cobalt_storage_metrics_helper.{h,cc}): - Adds an optional `pre_footprint_cleanup_task` closure parameter to `ScheduleCobaltStorageMetricsRecording()`. - At t=30s on the BEST_EFFORT background sequence: (1) Samples `/proc/self/io` `StartupReadKB` and `StartupWriteKB` first, before any one-time cleanup runs, so `unlink()` journal writes and directory scans do not inflate cold-start I/O metrics. (2) Executes `pre_footprint_cleanup_task` synchronously on the same background sequence if provided. (3) Re-samples `/proc/self/io` `write_bytes` after cleanup to initialize `StorageIoWriteRateTracker::InitializeBaseline()`, preventing cleanup writes from polluting `Cobalt.Storage.ProcessIo.WriteRateKBPerMin`. (4) Walks `SHELL_DIR_USER_DATA` and `DIR_CACHE` after cleanup to emit `Cobalt.Storage.UserData.StartupTotalSizeKB` and `Cobalt.Storage.DirCache.StartupTotalSizeKB`. - Adds `ScheduleCobaltStorageMetricsRecordingRunsCleanupBeforeFootprint` in `cobalt_storage_metrics_helper_unittest.cc`. 2. Golden UMA Verification Tooling (`cobalt/tools/uma/`): - Updates `storage_histograms.txt` (46 histograms) with `Browser.MainThreadsCongestion.RunningOnly` and `Browser.MainThreadsCongestion.RunningOnly.Initial`. - Adds `--max-polls` to `pull_uma_histogram_set_via_cdp.py` for bounded long-running soak verification (`--poll-interval 60 --max-polls 6`). Bug: 572861809, 573291594, 574085343 TAG=agy CONV=b4b48c2a-6f00-426d-97f9-4bd513201c84
haozheng-cobalt
added a commit
to haozheng-cobalt/cobalt
that referenced
this pull request
Oct 20, 2026
…s to storage tools Updates Cobalt's storage and UMA benchmarking tools to support multi-run warmup/migration benchmarks (Run youtube#1 migration purge at +30s followed by Run youtube#2 steady-state post-purge measurement) and startup latency telemetry: 1. cobalt/tools/uma/storage_histograms.txt: - Add Cobalt's core startup latency histograms (Cobalt.Startup.Time.NavigationDispatchToCommit, Cobalt.Startup.MilestoneReached, Cobalt.Startup.MilestoneDuration.) alongside Storage.DomStorage. and Cobalt.Storage. 2. cobalt/tools/uma/pull_uma_histogram_set_via_cdp.py: - Add --extra-args, --max-polls, --warmup-runs, --warmup-duration-s (default 35.0s), and --warmup-output-file to run warmup/migration launches before starting the measured UMA collection run. 3. cobalt/tools/storage/storage_monitor.py & storage_monitor_test.py: - Add --warmup-duration to execute a warmup/migration launch, record pre/post-warmup persistent footprint deltas in warmup_summary, reset per-run counters, and then run the measured CUJ. Bug: 499043721
haozheng-cobalt
added a commit
to haozheng-cobalt/cobalt
that referenced
this pull request
Oct 20, 2026
…s to storage tools Updates Cobalt's storage and UMA benchmarking tools to support multi-run warmup/migration benchmarks (Run youtube#1 migration purge at +30s followed by Run youtube#2 steady-state post-purge measurement) and startup latency telemetry: 1. cobalt/tools/uma/storage_histograms.txt: - Add Cobalt's core startup latency histograms (Cobalt.Startup.Time.NavigationDispatchToCommit, Cobalt.Startup.MilestoneReached, Cobalt.Startup.MilestoneDuration.) alongside Storage.DomStorage. and Cobalt.Storage. 2. cobalt/tools/uma/pull_uma_histogram_set_via_cdp.py: - Add --extra-args, --max-polls, --warmup-runs, --warmup-duration-s (default 35.0s), and --warmup-output-file to run warmup/migration launches before starting the measured UMA collection run. 3. cobalt/tools/storage/storage_monitor.py & storage_monitor_test.py: - Add --warmup-duration to execute a warmup/migration launch, record pre/post-warmup persistent footprint deltas in warmup_summary, reset per-run counters, and then run the measured CUJ. Bug: 499043721
haozheng-cobalt
added a commit
to haozheng-cobalt/cobalt
that referenced
this pull request
Oct 20, 2026
…s to CDP UMA tool Updates Cobalt's CDP UMA collection tool to support multi-run warmup/migration benchmarks (Run youtube#1 migration purge at +30s followed by Run youtube#2 steady-state post-purge measurement) and startup latency UMA attribution: - Adds --warmup-runs, --warmup-duration-s (default 35.0s), --warmup-output-file, --extra-args, --max-polls, --device-id, Kimono intent launch support, non-splash page target selection, and automatic BrowserStabilityMetrics .pma clearing to pull_uma_histogram_set_via_cdp.py. - Adds Cobalt.Startup.Time.NavigationDispatchToCommit, Cobalt.Startup.MilestoneReached, Cobalt.Startup.MilestoneDuration., and Browser.MainThreadsCongestion.RunningOnly* to storage_histograms.txt. Bug: 574085343, 572861809
haozheng-cobalt
added a commit
to haozheng-cobalt/cobalt
that referenced
this pull request
Nov 10, 2026
Add cobalt::features::kCobaltCodeCacheOptimization (disabled by default for controlled Finch/Mendel A/B experimentation) strictly within cobalt/browser/ without modifying Blink or base/: 1. Set WebPreferences::v8_cache_options to kCodeWithoutHeatCheck (cobalt_v8_code_cache_bypass_heat_check=true) instead of kDefault in CobaltContentBrowserClient::OverrideWebPreferences() so Launch youtube#1 after install, cache clear, or weekly JS updates produces deferred bytecode (via Blink's existing PostDelayedIdleTask queue from youtube#13167) for Launch youtube#2 instead of waiting until Launch youtube#3. 2. Increase GeneratedCodeCacheSettings JS capacity from 5 MiB to 10 MiB (cobalt_code_cache_size_mb=10, clamped to <= 1024 MiB against 32-bit overflow while Wasm stays capped at 1 MiB from youtube#13670) so ~4.6 MB of compiled Kabuki bytecode does not cross SimpleCache's 90% eviction watermark, and dynamically update Starboard's non-HTTP cache reserve in ComputeDefaultHttpCacheSize() without clobbering 0 or small budgets. 3. Record Cobalt.Storage.CodeCache.ConfiguredMaxSizeKB and add unit tests in CobaltContentBrowserClientTest and CobaltWebPrefsTest. (HTTP disk cache quota tuning is split into standalone cobalt::features::kCobaltHttpCacheQuota.) Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 TAG=agy CONV=b25ebd57-fb39-4a16-96b6-a4c885da89b0
haozheng-cobalt
added a commit
to haozheng-cobalt/cobalt
that referenced
this pull request
Nov 10, 2026
Add cobalt::features::kCobaltCodeCacheOptimization (disabled by default for controlled Finch/Mendel A/B experimentation) strictly within cobalt/browser/ without modifying Blink or base/: 1. Set WebPreferences::v8_cache_options to kCodeWithoutHeatCheck (cobalt_v8_code_cache_bypass_heat_check=true) instead of kDefault in CobaltContentBrowserClient::OverrideWebPreferences() so Launch youtube#1 after install, cache clear, or weekly JS updates produces deferred bytecode (via Blink's existing PostDelayedIdleTask queue from youtube#13167) for Launch youtube#2 instead of waiting until Launch youtube#3. 2. Increase GeneratedCodeCacheSettings JS capacity from 5 MiB to 10 MiB (cobalt_code_cache_size_mb=10, clamped to [1, 1024] MiB against 32-bit overflow while Wasm stays capped at 1 MiB from youtube#13670) so ~5.5 MiB of compiled Kabuki bytecode does not cross SimpleCache's 90% eviction watermark, and dynamically update Starboard's non-HTTP cache reserve in ComputeDefaultHttpCacheSize() without clobbering 0 or small budgets. 3. Add unit tests in CobaltContentBrowserClientTest and CobaltWebPrefsTest. (HTTP disk cache quota tuning is split into standalone cobalt::features::kCobaltHttpCacheQuota in youtube#13914.) Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 TAG=agy CONV=b25ebd57-fb39-4a16-96b6-a4c885da89b0
Awallky
pushed a commit
that referenced
this pull request
Nov 10, 2026
…t race (#13881) Fix post-test teardown flakiness in `cobalt_browsertests_loader` (and `cobalt_browsertests` on Starboard): 1. **Prevent UAF of `ContentMainDelegate` during fixture/launcher teardown**: On `IS_ANDROID || IS_IOS || IS_STARBOARD`, `ShellMainDelegate::RunProcess()` intentionally leaks `BrowserMainRunner` without calling `Shutdown()`. - In `ContentMainRunnerImplBrowserTest`, GTest's `TestInfo::Run()` destroys the test fixture (`DeleteSelf_()`) before `OnTestEnd()` (`[ OK ]`). Hold `mock_delegate_` in a `std::unique_ptr`, verify mock expectations explicitly in `TearDown()`, and release ownership on those platforms so background threads (`Chrome_InProcGpuThread`, `Chrome_InProcRendererThread`, `Chrome_IOThread`) do not dereference freed `ContentClient` or `MemorySystem` objects before `std::_Exit()`. - In `content::LaunchTests()` (`content/public/test/test_launcher.cc`), release `content_main_delegate` on `IS_STARBOARD` after `RunTestSuite()` returns so it remains valid until `std::_Exit()`. - In `BrowserTestBase::ProxyRunTestOnMainThreadLoop()` (`content/public/test/browser_test_base.cc`), reset `ShutdownHandler` and restore `SIGSEGV`/`SIGTERM` to `SIG_DFL` after the test body finishes. 2. **Fix `CobaltTestActivity` `ACTION_TEST_RUN_FINISHED` vs. `std::_Exit()` race**: Override `finishAndRemoveTask()` in `CobaltTestActivity.java` (invoked by `BaseStarboardBridge.requestStop()` when `SbSystemRequestStop()` runs) to send `mReporter.testRunFinished(Process.myPid())` before Activity teardown and `nativeSendStopEvent()` -> `std::_Exit()` terminate `:test_process`. ### Summarized CI Flakiness Addressed (Last 57 `evergreen` & 50 `linux` Runs) | Defect / Symptom | Affected Tests & Platforms | CI Flake Rate Before Fix | | :--- | :--- | :--- | | `[CRASH]` during fixture/launcher teardown (`mock_delegate_` / `content_main_delegate` UAF) | `ContentMainRunnerImplBrowserTest.StartupSequence` (and occasional `ExperimentConfigBrowserTest` / `H5vccRuntimeBrowserTest`) on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`45.6%`** (`26/57`) of `evergreen` CI runs failed on Attempt #1 (`38.6%` / `22/57` on `arm64-aosp`, `17.5%` / `10/57` on `arm-softfp-aosp`; `4` `main` runs left red) | | Post-test teardown `SIGSEGV` / `ShutdownHandler` race | `NavigationBaseBrowserTest.*`, `NavigationSuddenTerminationDisablerTypeBrowserTest.*` on `linux-x64x11` (`cobalt_browsertests`) | **`6.0%`** (`3/50`) of recent `linux` CI runs (`6.8%` in b/568023789) | | `E NativeTest: Test process <PID> died unexpectedly.` | All 11 active tests in `cobalt_browsertests_loader` on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`75.8%`** (`75/99`) of individual test invocations (6–10 out of 11 tests per run) | Bug: 568023789 Bug: 571969745 Bug: 576786536 Bug: 581094358 TAG=agy CONV=976f977c-602b-4cf1-a03b-a67e894b53e9
haozheng-cobalt
added a commit
to haozheng-cobalt/cobalt
that referenced
this pull request
Nov 11, 2026
Introduce cobalt::features::kCobaltCodeCacheOptimization (FEATURE_DISABLED_BY_DEFAULT) strictly in cobalt/browser/ (zero upstream/Blink/base/ changes) to eliminate cold-start V8 Code Cache self-eviction and two-launch bytecode warmup lag: 1. Bypass V8's 2-visit HasHotTimestamp gate in CobaltContentBrowserClient::OverrideWebPreferences() via V8CacheOptions::kCodeWithoutHeatCheck (CobaltCodeCacheOptimization_bypass_heat_check=true) so Launch youtube#1 after install, cache clear, or weekly JS updates caches deferred bytecode (via Blink's existing PostDelayedIdleTask queue from youtube#13167) for Launch youtube#2 instead of waiting until Launch youtube#3. 2. Increase GeneratedCodeCacheSettings JS capacity from 5242880 bytes (5 MiB) to 10485760 bytes (10 MiB) via CobaltCodeCacheOptimization_size_bytes (clamped to [1048576, 1073741824] bytes while Wasm stays capped at 1 MiB from youtube#13670) so ~5.5 MiB of compiled Kabuki bytecode does not cross SimpleCache's 90% eviction watermark, and dynamically update Starboard's non-HTTP cache reserve in ComputeDefaultHttpCacheSize() without clobbering 0 or small budgets. 3. Prefix Finch feature parameter names with the feature name per go/cobalt-finch-setup#naming-style-guide (youtube#13883), declare quota parameters directly in bytes (youtube#13914), and add unit tests in CobaltContentBrowserClientTest and CobaltWebPrefsTest (including combined composition with kCobaltHttpCacheQuota). Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625
haozheng-cobalt
added a commit
that referenced
this pull request
Nov 11, 2026
…ng (#13558) ### Motivation & Budget Rationale (`Code Cache` `5 -> 10 MiB` + `HttpCache` `25 -> 12 MiB` in #13914) Living Room TV platforms enforce a strict **`24 MiB` `DIR_CACHE` budget** (exceeding it triggers OS cache wipes or certification failures). Previously, Cobalt allocated **`25 MiB` to `HttpCache`** and **`5 MiB` to JS `Code Cache`**: - **Why `5 MiB` JS `Code Cache` was too small (self-eviction + 2-visit cold-start tax)**: - YouTube TV (`Kabuki`) compiles **`~5.5 MiB` (`5,610 KB`)** of core JS bytecode on every cold start. Because `SimpleCache` begins evicting entries at **90% capacity (`4.5 MiB` of a `5 MiB` cap)**, writing `5.5 MiB` into a `5 MiB` cache immediately self-evicted roughly half of the app's own bytecode (`4.66 -> 2.39 MiB`). - Compounded by Chromium's desktop `HasHotTimestamp` 2-visit rule (`V8CacheOptions::kDefault`), Launch #1 wrote only an 8-byte timestamp (`14 KB`) and refused to cache bytecode—forcing **two consecutive slow startups (`1.80 s` background V8 compile CPU)** after every install, cache clear, or weekly YouTube JS rollout. - **Why pairing `10 MiB` `Code Cache` (this PR) with `12 MiB` `HttpCache` (#13914) fits `DIR_CACHE <= 24 MiB`**: - A full warm YouTube TV Home load only consumes **`1.8 MiB`** of `HttpCache` (`15/15` cached resources preserved at `12 MiB` in #13914 while holding ~500 thumbnails), and an old thumbnail miss is a cheap ~20 ms background CDN fetch—whereas a V8 `Code Cache` miss burns **1.8 seconds of TV CPU** re-compiling megabytes of JS on cold boot. --- ### Summary of Changes Add `cobalt::features::kCobaltCodeCacheOptimization` (`FEATURE_DISABLED_BY_DEFAULT` for controlled 50/50 Finch/Mendel experimentation) strictly within `cobalt/browser/` (`4` files, `0` upstream/Blink/`base/` changes): 1. **First-launch bytecode caching (`V8CacheOptions::kCodeWithoutHeatCheck`)**: - Set `WebPreferences::v8_cache_options` to `blink::mojom::V8CacheOptions::kCodeWithoutHeatCheck` (`CobaltCodeCacheOptimization_bypass_heat_check = true`) in `CobaltContentBrowserClient::OverrideWebPreferences()`. - Combined with `main`'s existing `ThreadScheduler::PostDelayedIdleTask(1ms)` deferral (#13167), Launch #1 serializes startup-executed bytecode during renderer idle so **Launch #2 immediately hits `ConsumeCodeCache`** instead of waiting until Launch #3 (while avoiding `kFullCodeWithoutHeatCheck`'s synchronous eager-compile stalls and bytecode bloat). 2. **Raise `Code Cache/js` capacity (`5242880 -> 10485760` bytes / `5 MiB -> 10 MiB`) & preserve Starboard `24 MiB` budget**: - Configure `GeneratedCodeCacheSettings` JS capacity via `CobaltCodeCacheOptimization_size_bytes = 10485760` (declared directly in bytes per #13914 and prefixed with the feature name per `go/cobalt-finch-setup#naming-style-guide` / #13883, clamped to `[1048576, 1073741824]` bytes; `Code Cache/wasm` stays capped at `1 MiB` from #13670). - Dynamically update Starboard's non-HTTP cache reserve in `ComputeDefaultHttpCacheSize()` (`6 MiB` `CacheStorage` + `1 MiB` `wasm` + `js` cap + `1 MiB` headroom) without clobbering `0` or small budgets, composing cleanly with `kCobaltHttpCacheQuota` (#13914, `43c685c032c`). - Upstream `SimpleCache.Code.{CacheSizeOnInit,MaxCacheSizeOnInit}` (already allowlisted in Plx) track configured capacity and on-disk usage without custom histograms. --- ### Verification - **Unit tests**: - **Linux (`linux-x64x11_devel`)**: `20/20` passing in `cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"` (including combined `kCobaltCodeCacheOptimization` + `kCobaltHttpCacheQuota` Starboard `24 MiB` budget check). - **Android on-device (`android-arm_devel` on `sabrina`)**: `21/21` passing in `run_cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"`. - **On-device Storage Lab A/B (`sabrina`, Recipe A: 3 ABBA pairs x 25 s after `warmup_runs=1` + `--exit-flush`, `6/6` valid on Try 1)**: - `SimpleCache.Code.MaxCacheSizeOnInit`: `5,120 KB -> 10,240 KB` (`+100.0%` `[IMPROVED]`; live probe `CobaltCodeCacheOptimization_size_bytes/8388608` -> `8,192 KB`) - `SimpleCache.Code.CacheSizeOnInit`: `14 KB -> 5,610 KB` (`5.48 MiB` — exceeds the `5,120 KB` baseline cap and its `4.5 MiB` 90% eviction watermark on a single Home cold start, confirming why `kCodeWithoutHeatCheck` and the `10 MiB` cap ship together) - `V8.CompileScript.CacheBehaviour` (`ConsumeCodeCache`): `0/14 (0%) -> 13/14 (92.9%)` external scripts (`WebCore.Scripts.V8CodeCacheMetadata.Get:CodeCache`: `0/27 -> 26/27`, `96.3%`) - `V8.CompileScriptMicroSeconds.BackgroundThread`: `1,800,809 us -> 514 us` (`-100.0%` `[IMPROVED]`; total background compile + `ConsumeCache.BackgroundThread` `1.80 s -> 0.309 s`, **`-82.9%`**) - `Cobalt.Storage.ProcessIo.StartupWriteKB` (Launch #2): `4,268 KB -> 1,996 KB` (**`-53.3%`**), with **`0` `[REGRESSED]` rows** across all `136` cold-start (`S1`) and `30` exit-flush (`S2 - S1`) metrics. - *Finch rollout watchpoint*: Monitor P99 Launch #1 startup latency on 1 GB eMMC devices to confirm the `+5.5 MiB` first-launch idle bytecode serialization does not contend on worn flash. Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625
kjyoun
added a commit
to kjyoun/cobalt
that referenced
this pull request
Nov 14, 2026
…aces
Why this change is needed (end-to-end picture on Android TV / Sony mt5895):
On Android TV SoCs whose vendor OMX/Codec2 HAL releases hardware video
decoder instances asynchronously in the background ("phantom release",
such as Sony mt5895 MtkOmxVdec where MediaCodec.release() returns in
approx. 10 ms while hardware reclaim continues asynchronously), any
back-to-back destroy-then-create of the hardware MediaCodec collides
with the previous instance's cleanup, causing either 1.6-4.2 s
Presenting/Seek stalls (which on TV Shorts >= 2-3 s also trip YouTube's
slow_seek_shorts watchdog into destroying and recreating <video>) or
CodecException start() / OMX decode failures.
Previously, MediaCodecVideoDecoder and MediaCodecBridge had three
stacked issues that triggered unnecessary back-to-back codec churn or
aborted immediately on transient HAL reclaim races:
1. Misclassifying non-BT.709 SDR as HDR (`!IsIdentity()`):
- <= 480p SD BT.601 SDR streams (kSbMediaPrimaryIdSmpte170M, e.g.
itag 397 AV1 480p / itag 244 VP9 480p) and Unspecified color
metadata failed `IsIdentity()`, tearing down and recreating
MediaCodec on Frame youtube#1 and across 480p <-> 1080p flushed seeks even
though MediaCodecBridge::CreateVideoMediaCodec() maps Smpte170M to
COLOR_VALUE_UNKNOWN and passes `j_color_info = nullptr` both times.
- Full-range BT.709 SDR (`kSbMediaRangeIdFull`) also failed
`IsIdentity()` and constructed a non-null ColorInfo, causing
MediaCodecBridge.java on HDR-capable TVs to attach fabricated HDR10
static metadata (defaultMaxCll = 1000, defaultMaxFall = 200) to an
8-bit SDR stream.
Fix: Introduce `ShouldConfigureHdrColorMetadata()` in media_common.h
(requiring PQ/ST2084 or HLG transfer plus valid Android primary/range
mappings) and `maybeConfigureHdrColorInfo()` in MediaCodecBridge.java
(restricting KEY_HDR_STATIC_INFO to PQ/ST2084).
2. Eager constructor ignoring `stream_config.video_stream_info.color_metadata`:
- Even though SbPlayerBridge::UpdateVideoConfig() already populates
color_metadata before SbPlayerCreate(), MediaCodecVideoDecoder's
constructor left `color_metadata_` as std::nullopt during eager
InitializeCodec(), creating a throwaway SDR MediaCodec only to
destroy and recreate it milliseconds later on Frame youtube#1.
Fix: Seed `color_metadata_` in the constructor when
`ShouldConfigureHdrColorMetadata()` is true, and use
`NeedsCodecTransition()` on Frame youtube#1 so the codec is only rebuilt if
in-band bitstream metadata genuinely differs from the init segment.
3. Zero retry when synchronous MediaCodec creation races phantom release:
- Legitimate transitions (true SDR <-> HDR gapless Shorts, non-flush
Reset(), or rapid cross-player switches) can still overlap async
vendor HAL teardown and fail createByCodecName()/configure()/start()
synchronously.
Fix: Add bounded linear-backoff retry inside InitializeCodec()
(`kMediaVideoCodecCreationMaxRetries`, default 3 retries = 50 + 100 +
150 ms, clamped at 5 and aborted early on OnSurfaceDestroyed()).
Bug: 581505988
Bug: 584742666
Bug: 581989550
TAG=agy
CONV=a19ee6c2-9df9-4275-80aa-f4896dffdfd7
cobalt-github-releaser-bot
pushed a commit
that referenced
this pull request
Nov 19, 2026
…crash and exit broadcast race Refer to original PR: #13881 Fix post-test teardown flakiness in `cobalt_browsertests_loader` (and `cobalt_browsertests` on Starboard): 1. **Prevent UAF of `ContentMainDelegate` during fixture/launcher teardown**: On `IS_ANDROID || IS_IOS || IS_STARBOARD`, `ShellMainDelegate::RunProcess()` intentionally leaks `BrowserMainRunner` without calling `Shutdown()`. - In `ContentMainRunnerImplBrowserTest`, GTest's `TestInfo::Run()` destroys the test fixture (`DeleteSelf_()`) before `OnTestEnd()` (`[ OK ]`). Hold `mock_delegate_` in a `std::unique_ptr`, verify mock expectations explicitly in `TearDown()`, and release ownership on those platforms so background threads (`Chrome_InProcGpuThread`, `Chrome_InProcRendererThread`, `Chrome_IOThread`) do not dereference freed `ContentClient` or `MemorySystem` objects before `std::_Exit()`. - In `content::LaunchTests()` (`content/public/test/test_launcher.cc`), release `content_main_delegate` on `IS_STARBOARD` after `RunTestSuite()` returns so it remains valid until `std::_Exit()`. - In `BrowserTestBase::ProxyRunTestOnMainThreadLoop()` (`content/public/test/browser_test_base.cc`), reset `ShutdownHandler` and restore `SIGSEGV`/`SIGTERM` to `SIG_DFL` after the test body finishes. 2. **Fix `CobaltTestActivity` `ACTION_TEST_RUN_FINISHED` vs. `std::_Exit()` race**: Override `finishAndRemoveTask()` in `CobaltTestActivity.java` (invoked by `BaseStarboardBridge.requestStop()` when `SbSystemRequestStop()` runs) to send `mReporter.testRunFinished(Process.myPid())` before Activity teardown and `nativeSendStopEvent()` -> `std::_Exit()` terminate `:test_process`. ### Summarized CI Flakiness Addressed (Last 57 `evergreen` & 50 `linux` Runs) | Defect / Symptom | Affected Tests & Platforms | CI Flake Rate Before Fix | | :--- | :--- | :--- | | `[CRASH]` during fixture/launcher teardown (`mock_delegate_` / `content_main_delegate` UAF) | `ContentMainRunnerImplBrowserTest.StartupSequence` (and occasional `ExperimentConfigBrowserTest` / `H5vccRuntimeBrowserTest`) on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`45.6%`** (`26/57`) of `evergreen` CI runs failed on Attempt #1 (`38.6%` / `22/57` on `arm64-aosp`, `17.5%` / `10/57` on `arm-softfp-aosp`; `4` `main` runs left red) | | Post-test teardown `SIGSEGV` / `ShutdownHandler` race | `NavigationBaseBrowserTest.*`, `NavigationSuddenTerminationDisablerTypeBrowserTest.*` on `linux-x64x11` (`cobalt_browsertests`) | **`6.0%`** (`3/50`) of recent `linux` CI runs (`6.8%` in b/568023789) | | `E NativeTest: Test process <PID> died unexpectedly.` | All 11 active tests in `cobalt_browsertests_loader` on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`75.8%`** (`75/99`) of individual test invocations (6–10 out of 11 tests per run) | Bug: 568023789 Bug: 571969745 Bug: 576786536 Bug: 581094358 TAG=agy CONV=976f977c-602b-4cf1-a03b-a67e894b53e9 (cherry picked from commit edcee53)
cobalt-roller-and-merger Bot
pushed a commit
that referenced
this pull request
Nov 23, 2026
…crash and exit broadcast race Refer to original PR: #13881 Fix post-test teardown flakiness in `cobalt_browsertests_loader` (and `cobalt_browsertests` on Starboard): 1. **Prevent UAF of `ContentMainDelegate` during fixture/launcher teardown**: On `IS_ANDROID || IS_IOS || IS_STARBOARD`, `ShellMainDelegate::RunProcess()` intentionally leaks `BrowserMainRunner` without calling `Shutdown()`. - In `ContentMainRunnerImplBrowserTest`, GTest's `TestInfo::Run()` destroys the test fixture (`DeleteSelf_()`) before `OnTestEnd()` (`[ OK ]`). Hold `mock_delegate_` in a `std::unique_ptr`, verify mock expectations explicitly in `TearDown()`, and release ownership on those platforms so background threads (`Chrome_InProcGpuThread`, `Chrome_InProcRendererThread`, `Chrome_IOThread`) do not dereference freed `ContentClient` or `MemorySystem` objects before `std::_Exit()`. - In `content::LaunchTests()` (`content/public/test/test_launcher.cc`), release `content_main_delegate` on `IS_STARBOARD` after `RunTestSuite()` returns so it remains valid until `std::_Exit()`. - In `BrowserTestBase::ProxyRunTestOnMainThreadLoop()` (`content/public/test/browser_test_base.cc`), reset `ShutdownHandler` and restore `SIGSEGV`/`SIGTERM` to `SIG_DFL` after the test body finishes. 2. **Fix `CobaltTestActivity` `ACTION_TEST_RUN_FINISHED` vs. `std::_Exit()` race**: Override `finishAndRemoveTask()` in `CobaltTestActivity.java` (invoked by `BaseStarboardBridge.requestStop()` when `SbSystemRequestStop()` runs) to send `mReporter.testRunFinished(Process.myPid())` before Activity teardown and `nativeSendStopEvent()` -> `std::_Exit()` terminate `:test_process`. ### Summarized CI Flakiness Addressed (Last 57 `evergreen` & 50 `linux` Runs) | Defect / Symptom | Affected Tests & Platforms | CI Flake Rate Before Fix | | :--- | :--- | :--- | | `[CRASH]` during fixture/launcher teardown (`mock_delegate_` / `content_main_delegate` UAF) | `ContentMainRunnerImplBrowserTest.StartupSequence` (and occasional `ExperimentConfigBrowserTest` / `H5vccRuntimeBrowserTest`) on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`45.6%`** (`26/57`) of `evergreen` CI runs failed on Attempt #1 (`38.6%` / `22/57` on `arm64-aosp`, `17.5%` / `10/57` on `arm-softfp-aosp`; `4` `main` runs left red) | | Post-test teardown `SIGSEGV` / `ShutdownHandler` race | `NavigationBaseBrowserTest.*`, `NavigationSuddenTerminationDisablerTypeBrowserTest.*` on `linux-x64x11` (`cobalt_browsertests`) | **`6.0%`** (`3/50`) of recent `linux` CI runs (`6.8%` in b/568023789) | | `E NativeTest: Test process <PID> died unexpectedly.` | All 11 active tests in `cobalt_browsertests_loader` on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`75.8%`** (`75/99`) of individual test invocations (6–10 out of 11 tests per run) | Bug: 568023789 Bug: 571969745 Bug: 576786536 Bug: 581094358 TAG=agy CONV=976f977c-602b-4cf1-a03b-a67e894b53e9 (cherry picked from commit edcee53)
cobalt-github-releaser-bot
pushed a commit
that referenced
this pull request
Nov 24, 2026
…crash and exit broadcast race Refer to original PR: #13881 Fix post-test teardown flakiness in `cobalt_browsertests_loader` (and `cobalt_browsertests` on Starboard): 1. **Prevent UAF of `ContentMainDelegate` during fixture/launcher teardown**: On `IS_ANDROID || IS_IOS || IS_STARBOARD`, `ShellMainDelegate::RunProcess()` intentionally leaks `BrowserMainRunner` without calling `Shutdown()`. - In `ContentMainRunnerImplBrowserTest`, GTest's `TestInfo::Run()` destroys the test fixture (`DeleteSelf_()`) before `OnTestEnd()` (`[ OK ]`). Hold `mock_delegate_` in a `std::unique_ptr`, verify mock expectations explicitly in `TearDown()`, and release ownership on those platforms so background threads (`Chrome_InProcGpuThread`, `Chrome_InProcRendererThread`, `Chrome_IOThread`) do not dereference freed `ContentClient` or `MemorySystem` objects before `std::_Exit()`. - In `content::LaunchTests()` (`content/public/test/test_launcher.cc`), release `content_main_delegate` on `IS_STARBOARD` after `RunTestSuite()` returns so it remains valid until `std::_Exit()`. - In `BrowserTestBase::ProxyRunTestOnMainThreadLoop()` (`content/public/test/browser_test_base.cc`), reset `ShutdownHandler` and restore `SIGSEGV`/`SIGTERM` to `SIG_DFL` after the test body finishes. 2. **Fix `CobaltTestActivity` `ACTION_TEST_RUN_FINISHED` vs. `std::_Exit()` race**: Override `finishAndRemoveTask()` in `CobaltTestActivity.java` (invoked by `BaseStarboardBridge.requestStop()` when `SbSystemRequestStop()` runs) to send `mReporter.testRunFinished(Process.myPid())` before Activity teardown and `nativeSendStopEvent()` -> `std::_Exit()` terminate `:test_process`. ### Summarized CI Flakiness Addressed (Last 57 `evergreen` & 50 `linux` Runs) | Defect / Symptom | Affected Tests & Platforms | CI Flake Rate Before Fix | | :--- | :--- | :--- | | `[CRASH]` during fixture/launcher teardown (`mock_delegate_` / `content_main_delegate` UAF) | `ContentMainRunnerImplBrowserTest.StartupSequence` (and occasional `ExperimentConfigBrowserTest` / `H5vccRuntimeBrowserTest`) on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`45.6%`** (`26/57`) of `evergreen` CI runs failed on Attempt #1 (`38.6%` / `22/57` on `arm64-aosp`, `17.5%` / `10/57` on `arm-softfp-aosp`; `4` `main` runs left red) | | Post-test teardown `SIGSEGV` / `ShutdownHandler` race | `NavigationBaseBrowserTest.*`, `NavigationSuddenTerminationDisablerTypeBrowserTest.*` on `linux-x64x11` (`cobalt_browsertests`) | **`6.0%`** (`3/50`) of recent `linux` CI runs (`6.8%` in b/568023789) | | `E NativeTest: Test process <PID> died unexpectedly.` | All 11 active tests in `cobalt_browsertests_loader` on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`75.8%`** (`75/99`) of individual test invocations (6–10 out of 11 tests per run) | Bug: 568023789 Bug: 571969745 Bug: 576786536 Bug: 581094358 TAG=agy CONV=976f977c-602b-4cf1-a03b-a67e894b53e9 (cherry picked from commit edcee53)
andrewsavage1
pushed a commit
that referenced
this pull request
Nov 24, 2026
…crash and exit broadcast race Refer to original PR: #13881 Fix post-test teardown flakiness in `cobalt_browsertests_loader` (and `cobalt_browsertests` on Starboard): 1. **Prevent UAF of `ContentMainDelegate` during fixture/launcher teardown**: On `IS_ANDROID || IS_IOS || IS_STARBOARD`, `ShellMainDelegate::RunProcess()` intentionally leaks `BrowserMainRunner` without calling `Shutdown()`. - In `ContentMainRunnerImplBrowserTest`, GTest's `TestInfo::Run()` destroys the test fixture (`DeleteSelf_()`) before `OnTestEnd()` (`[ OK ]`). Hold `mock_delegate_` in a `std::unique_ptr`, verify mock expectations explicitly in `TearDown()`, and release ownership on those platforms so background threads (`Chrome_InProcGpuThread`, `Chrome_InProcRendererThread`, `Chrome_IOThread`) do not dereference freed `ContentClient` or `MemorySystem` objects before `std::_Exit()`. - In `content::LaunchTests()` (`content/public/test/test_launcher.cc`), release `content_main_delegate` on `IS_STARBOARD` after `RunTestSuite()` returns so it remains valid until `std::_Exit()`. - In `BrowserTestBase::ProxyRunTestOnMainThreadLoop()` (`content/public/test/browser_test_base.cc`), reset `ShutdownHandler` and restore `SIGSEGV`/`SIGTERM` to `SIG_DFL` after the test body finishes. 2. **Fix `CobaltTestActivity` `ACTION_TEST_RUN_FINISHED` vs. `std::_Exit()` race**: Override `finishAndRemoveTask()` in `CobaltTestActivity.java` (invoked by `BaseStarboardBridge.requestStop()` when `SbSystemRequestStop()` runs) to send `mReporter.testRunFinished(Process.myPid())` before Activity teardown and `nativeSendStopEvent()` -> `std::_Exit()` terminate `:test_process`. ### Summarized CI Flakiness Addressed (Last 57 `evergreen` & 50 `linux` Runs) | Defect / Symptom | Affected Tests & Platforms | CI Flake Rate Before Fix | | :--- | :--- | :--- | | `[CRASH]` during fixture/launcher teardown (`mock_delegate_` / `content_main_delegate` UAF) | `ContentMainRunnerImplBrowserTest.StartupSequence` (and occasional `ExperimentConfigBrowserTest` / `H5vccRuntimeBrowserTest`) on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`45.6%`** (`26/57`) of `evergreen` CI runs failed on Attempt #1 (`38.6%` / `22/57` on `arm64-aosp`, `17.5%` / `10/57` on `arm-softfp-aosp`; `4` `main` runs left red) | | Post-test teardown `SIGSEGV` / `ShutdownHandler` race | `NavigationBaseBrowserTest.*`, `NavigationSuddenTerminationDisablerTypeBrowserTest.*` on `linux-x64x11` (`cobalt_browsertests`) | **`6.0%`** (`3/50`) of recent `linux` CI runs (`6.8%` in b/568023789) | | `E NativeTest: Test process <PID> died unexpectedly.` | All 11 active tests in `cobalt_browsertests_loader` on `evergreen-arm64-aosp` & `evergreen-arm-softfp-aosp` | **`75.8%`** (`75/99`) of individual test invocations (6–10 out of 11 tests per run) | Bug: 568023789 Bug: 571969745 Bug: 576786536 Bug: 581094358 TAG=agy CONV=976f977c-602b-4cf1-a03b-a67e894b53e9 (cherry picked from commit edcee53)
andrewsavage1
pushed a commit
that referenced
this pull request
Nov 24, 2026
…ta and first-launch bytecode caching Refer to original PR: #13558 ### Motivation & Budget Rationale (`Code Cache` `5 -> 10 MiB` + `HttpCache` `25 -> 12 MiB` in #13914) Living Room TV platforms enforce a strict **`24 MiB` `DIR_CACHE` budget** (exceeding it triggers OS cache wipes or certification failures). Previously, Cobalt allocated **`25 MiB` to `HttpCache`** and **`5 MiB` to JS `Code Cache`**: - **Why `5 MiB` JS `Code Cache` was too small (self-eviction + 2-visit cold-start tax)**: - YouTube TV (`Kabuki`) compiles **`~5.5 MiB` (`5,610 KB`)** of core JS bytecode on every cold start. Because `SimpleCache` begins evicting entries at **90% capacity (`4.5 MiB` of a `5 MiB` cap)**, writing `5.5 MiB` into a `5 MiB` cache immediately self-evicted roughly half of the app's own bytecode (`4.66 -> 2.39 MiB`). - Compounded by Chromium's desktop `HasHotTimestamp` 2-visit rule (`V8CacheOptions::kDefault`), Launch #1 wrote only an 8-byte timestamp (`14 KB`) and refused to cache bytecode—forcing **two consecutive slow startups (`1.80 s` background V8 compile CPU)** after every install, cache clear, or weekly YouTube JS rollout. - **Why pairing `10 MiB` `Code Cache` (this PR) with `12 MiB` `HttpCache` (#13914) fits `DIR_CACHE <= 24 MiB`**: - A full warm YouTube TV Home load only consumes **`1.8 MiB`** of `HttpCache` (`15/15` cached resources preserved at `12 MiB` in #13914 while holding ~500 thumbnails), and an old thumbnail miss is a cheap ~20 ms background CDN fetch—whereas a V8 `Code Cache` miss burns **1.8 seconds of TV CPU** re-compiling megabytes of JS on cold boot. --- ### Summary of Changes Add `cobalt::features::kCobaltCodeCacheOptimization` (`FEATURE_DISABLED_BY_DEFAULT` for controlled 50/50 Finch/Mendel experimentation) strictly within `cobalt/browser/` (`4` files, `0` upstream/Blink/`base/` changes): 1. **First-launch bytecode caching (`V8CacheOptions::kCodeWithoutHeatCheck`)**: - Set `WebPreferences::v8_cache_options` to `blink::mojom::V8CacheOptions::kCodeWithoutHeatCheck` (`CobaltCodeCacheOptimization_bypass_heat_check = true`) in `CobaltContentBrowserClient::OverrideWebPreferences()`. - Combined with `main`'s existing `ThreadScheduler::PostDelayedIdleTask(1ms)` deferral (#13167), Launch #1 serializes startup-executed bytecode during renderer idle so **Launch #2 immediately hits `ConsumeCodeCache`** instead of waiting until Launch #3 (while avoiding `kFullCodeWithoutHeatCheck`'s synchronous eager-compile stalls and bytecode bloat). 2. **Raise `Code Cache/js` capacity (`5242880 -> 10485760` bytes / `5 MiB -> 10 MiB`) & preserve Starboard `24 MiB` budget**: - Configure `GeneratedCodeCacheSettings` JS capacity via `CobaltCodeCacheOptimization_size_bytes = 10485760` (declared directly in bytes per #13914 and prefixed with the feature name per `go/cobalt-finch-setup#naming-style-guide` / #13883, clamped to `[1048576, 1073741824]` bytes; `Code Cache/wasm` stays capped at `1 MiB` from #13670). - Dynamically update Starboard's non-HTTP cache reserve in `ComputeDefaultHttpCacheSize()` (`6 MiB` `CacheStorage` + `1 MiB` `wasm` + `js` cap + `1 MiB` headroom) without clobbering `0` or small budgets, composing cleanly with `kCobaltHttpCacheQuota` (#13914, `43c685c032c`). - Upstream `SimpleCache.Code.{CacheSizeOnInit,MaxCacheSizeOnInit}` (already allowlisted in Plx) track configured capacity and on-disk usage without custom histograms. --- ### Verification - **Unit tests**: - **Linux (`linux-x64x11_devel`)**: `20/20` passing in `cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"` (including combined `kCobaltCodeCacheOptimization` + `kCobaltHttpCacheQuota` Starboard `24 MiB` budget check). - **Android on-device (`android-arm_devel` on `sabrina`)**: `21/21` passing in `run_cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"`. - **On-device Storage Lab A/B (`sabrina`, Recipe A: 3 ABBA pairs x 25 s after `warmup_runs=1` + `--exit-flush`, `6/6` valid on Try 1)**: - `SimpleCache.Code.MaxCacheSizeOnInit`: `5,120 KB -> 10,240 KB` (`+100.0%` `[IMPROVED]`; live probe `CobaltCodeCacheOptimization_size_bytes/8388608` -> `8,192 KB`) - `SimpleCache.Code.CacheSizeOnInit`: `14 KB -> 5,610 KB` (`5.48 MiB` — exceeds the `5,120 KB` baseline cap and its `4.5 MiB` 90% eviction watermark on a single Home cold start, confirming why `kCodeWithoutHeatCheck` and the `10 MiB` cap ship together) - `V8.CompileScript.CacheBehaviour` (`ConsumeCodeCache`): `0/14 (0%) -> 13/14 (92.9%)` external scripts (`WebCore.Scripts.V8CodeCacheMetadata.Get:CodeCache`: `0/27 -> 26/27`, `96.3%`) - `V8.CompileScriptMicroSeconds.BackgroundThread`: `1,800,809 us -> 514 us` (`-100.0%` `[IMPROVED]`; total background compile + `ConsumeCache.BackgroundThread` `1.80 s -> 0.309 s`, **`-82.9%`**) - `Cobalt.Storage.ProcessIo.StartupWriteKB` (Launch #2): `4,268 KB -> 1,996 KB` (**`-53.3%`**), with **`0` `[REGRESSED]` rows** across all `136` cold-start (`S1`) and `30` exit-flush (`S2 - S1`) metrics. - *Finch rollout watchpoint*: Monitor P99 Launch #1 startup latency on 1 GB eMMC devices to confirm the `+5.5 MiB` first-launch idle bytecode serialization does not contend on worn flash. Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 (cherry picked from commit 7f86976)
andrewsavage1
added a commit
that referenced
this pull request
Nov 24, 2026
…ta and first-launch bytecode caching (#14244) Refer to original PR: #13558 ### Motivation & Budget Rationale (`Code Cache` `5 -> 10 MiB` + `HttpCache` `25 -> 12 MiB` in #13914) Living Room TV platforms enforce a strict **`24 MiB` `DIR_CACHE` budget** (exceeding it triggers OS cache wipes or certification failures). Previously, Cobalt allocated **`25 MiB` to `HttpCache`** and **`5 MiB` to JS `Code Cache`**: - **Why `5 MiB` JS `Code Cache` was too small (self-eviction + 2-visit cold-start tax)**: - YouTube TV (`Kabuki`) compiles **`~5.5 MiB` (`5,610 KB`)** of core JS bytecode on every cold start. Because `SimpleCache` begins evicting entries at **90% capacity (`4.5 MiB` of a `5 MiB` cap)**, writing `5.5 MiB` into a `5 MiB` cache immediately self-evicted roughly half of the app's own bytecode (`4.66 -> 2.39 MiB`). - Compounded by Chromium's desktop `HasHotTimestamp` 2-visit rule (`V8CacheOptions::kDefault`), Launch #1 wrote only an 8-byte timestamp (`14 KB`) and refused to cache bytecode—forcing **two consecutive slow startups (`1.80 s` background V8 compile CPU)** after every install, cache clear, or weekly YouTube JS rollout. - **Why pairing `10 MiB` `Code Cache` (this PR) with `12 MiB` `HttpCache` (#13914) fits `DIR_CACHE <= 24 MiB`**: - A full warm YouTube TV Home load only consumes **`1.8 MiB`** of `HttpCache` (`15/15` cached resources preserved at `12 MiB` in #13914 while holding ~500 thumbnails), and an old thumbnail miss is a cheap ~20 ms background CDN fetch—whereas a V8 `Code Cache` miss burns **1.8 seconds of TV CPU** re-compiling megabytes of JS on cold boot. --- ### Summary of Changes Add `cobalt::features::kCobaltCodeCacheOptimization` (`FEATURE_DISABLED_BY_DEFAULT` for controlled 50/50 Finch/Mendel experimentation) strictly within `cobalt/browser/` (`4` files, `0` upstream/Blink/`base/` changes): 1. **First-launch bytecode caching (`V8CacheOptions::kCodeWithoutHeatCheck`)**: - Set `WebPreferences::v8_cache_options` to `blink::mojom::V8CacheOptions::kCodeWithoutHeatCheck` (`CobaltCodeCacheOptimization_bypass_heat_check = true`) in `CobaltContentBrowserClient::OverrideWebPreferences()`. - Combined with `main`'s existing `ThreadScheduler::PostDelayedIdleTask(1ms)` deferral (#13167), Launch #1 serializes startup-executed bytecode during renderer idle so **Launch #2 immediately hits `ConsumeCodeCache`** instead of waiting until Launch #3 (while avoiding `kFullCodeWithoutHeatCheck`'s synchronous eager-compile stalls and bytecode bloat). 2. **Raise `Code Cache/js` capacity (`5242880 -> 10485760` bytes / `5 MiB -> 10 MiB`) & preserve Starboard `24 MiB` budget**: - Configure `GeneratedCodeCacheSettings` JS capacity via `CobaltCodeCacheOptimization_size_bytes = 10485760` (declared directly in bytes per #13914 and prefixed with the feature name per `go/cobalt-finch-setup#naming-style-guide` / #13883, clamped to `[1048576, 1073741824]` bytes; `Code Cache/wasm` stays capped at `1 MiB` from #13670). - Dynamically update Starboard's non-HTTP cache reserve in `ComputeDefaultHttpCacheSize()` (`6 MiB` `CacheStorage` + `1 MiB` `wasm` + `js` cap + `1 MiB` headroom) without clobbering `0` or small budgets, composing cleanly with `kCobaltHttpCacheQuota` (#13914, `43c685c032c`). - Upstream `SimpleCache.Code.{CacheSizeOnInit,MaxCacheSizeOnInit}` (already allowlisted in Plx) track configured capacity and on-disk usage without custom histograms. --- ### Verification - **Unit tests**: - **Linux (`linux-x64x11_devel`)**: `20/20` passing in `cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"` (including combined `kCobaltCodeCacheOptimization` + `kCobaltHttpCacheQuota` Starboard `24 MiB` budget check). - **Android on-device (`android-arm_devel` on `sabrina`)**: `21/21` passing in `run_cobalt_unittests --gtest_filter="CobaltContentBrowserClient*:CobaltWebPrefsTest*"`. - **On-device Storage Lab A/B (`sabrina`, Recipe A: 3 ABBA pairs x 25 s after `warmup_runs=1` + `--exit-flush`, `6/6` valid on Try 1)**: - `SimpleCache.Code.MaxCacheSizeOnInit`: `5,120 KB -> 10,240 KB` (`+100.0%` `[IMPROVED]`; live probe `CobaltCodeCacheOptimization_size_bytes/8388608` -> `8,192 KB`) - `SimpleCache.Code.CacheSizeOnInit`: `14 KB -> 5,610 KB` (`5.48 MiB` — exceeds the `5,120 KB` baseline cap and its `4.5 MiB` 90% eviction watermark on a single Home cold start, confirming why `kCodeWithoutHeatCheck` and the `10 MiB` cap ship together) - `V8.CompileScript.CacheBehaviour` (`ConsumeCodeCache`): `0/14 (0%) -> 13/14 (92.9%)` external scripts (`WebCore.Scripts.V8CodeCacheMetadata.Get:CodeCache`: `0/27 -> 26/27`, `96.3%`) - `V8.CompileScriptMicroSeconds.BackgroundThread`: `1,800,809 us -> 514 us` (`-100.0%` `[IMPROVED]`; total background compile + `ConsumeCache.BackgroundThread` `1.80 s -> 0.309 s`, **`-82.9%`**) - `Cobalt.Storage.ProcessIo.StartupWriteKB` (Launch #2): `4,268 KB -> 1,996 KB` (**`-53.3%`**), with **`0` `[REGRESSED]` rows** across all `136` cold-start (`S1`) and `30` exit-flush (`S2 - S1`) metrics. - *Finch rollout watchpoint*: Monitor P99 Launch #1 startup latency on 1 GB eMMC devices to confirm the `+5.5 MiB` first-launch idle bytecode serialization does not contend on worn flash. Bug: 576699738 Bug: 558433644 Bug: 565045865 Bug: 567569625 (cherry picked from commit 7f86976) --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub> --------- Co-authored-by: Hao <131711973+haozheng-cobalt@users.noreply.github.com> Co-authored-by: Andrew Savage <andrewsavage@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge changes to generated documentation from pull-request branch to gh-pages branch.