Skip to content

Commit

Permalink
Merge branch 'youtube:main' into write-duration-eos
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonzhangxx committed Feb 5, 2024
2 parents 3e31cc7 + 1ae8d5e commit b1a7d3e
Show file tree
Hide file tree
Showing 1,801 changed files with 55,418 additions and 36,965 deletions.
68 changes: 27 additions & 41 deletions .github/actions/on_device_tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ runs:
echo "USE_SHARDING=1" >> $GITHUB_ENV
fi
shell: bash
- name: trigger ${{ env.SHARD_NAME }} tests on ${{ matrix.platform }} platform
- name: run ${{ env.SHARD_NAME }} tests on ${{ matrix.platform }} platform
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -59,44 +59,30 @@ runs:
GITHUB_COMMIT_AUTHOR_EMAIL: ${{ github.event.commits[0].author.email }}
run: |
set -uxe
SESSION_ID=$(
python3 tools/on_device_tests_gateway_client.py \
--token ${GITHUB_TOKEN} \
--change_id "${GITHUB_PR_HEAD_SHA:-$GITHUB_SHA}" \
trigger \
--test_type ${{ env.TEST_TYPE }} \
--platform ${{ matrix.target_platform }} \
--config ${{ matrix.config }} \
--tag cobalt_github_${GITHUB_EVENT_NAME} \
--builder_name github_${{ matrix.platform }}_tests \
--build_number ${GITHUB_RUN_NUMBER} \
${LOADER_PLATFORM:+"--loader_config" "$LOADER_CONFIG"} \
${LOADER_PLATFORM:+"--loader_platform" "$LOADER_PLATFORM"} \
${DIMENSION:+"--dimension" "$DIMENSION"} \
${USE_SHARDING:+"--unittest_shard_index" "${{ matrix.shard }}"} \
${ON_DEVICE_TEST_ATTEMPTS:+"--test_attempts" "$ON_DEVICE_TEST_ATTEMPTS"} \
--archive_path gs://${PROJECT_NAME}-test-artifacts/${WORKFLOW}/${GITHUB_RUN_NUMBER}/${{ matrix.platform }}_${{ matrix.config }}/artifacts.tar \
--label github \
--label ${GITHUB_EVENT_NAME} \
--label ${WORKFLOW} \
--label actor-${GITHUB_ACTOR} \
--label actor_id-${GITHUB_ACTOR_ID} \
--label triggering_actor-${GITHUB_TRIGGERING_ACTOR} \
--label sha-${GITHUB_SHA} \
--label repository-${GITHUB_REPO} \
--label author-${GITHUB_PR_HEAD_USER_LOGIN:-$GITHUB_COMMIT_AUTHOR_USERNAME} \
--label author_id-${GITHUB_PR_HEAD_USER_ID:-$GITHUB_COMMIT_AUTHOR_EMAIL}
)
echo "SESSION_ID=$SESSION_ID" >> $GITHUB_ENV
shell: bash
- name: watch ${{ env.SHARD_NAME }} tests on ${{ matrix.platform }} platform
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_SHA: ${{ github.sha }}
run: |
set -uxe
python3 tools/on_device_tests_gateway_client.py \
--token "${GITHUB_TOKEN}" \
--change_id "${GITHUB_SHA}" \
watch ${{ env.SESSION_ID }}
python3 -u tools/on_device_tests_gateway_client.py \
--token ${GITHUB_TOKEN} \
--change_id "${GITHUB_PR_HEAD_SHA:-$GITHUB_SHA}" \
trigger \
--test_type ${{ env.TEST_TYPE }} \
--platform ${{ matrix.target_platform }} \
--config ${{ matrix.config }} \
--tag cobalt_github_${GITHUB_EVENT_NAME} \
--builder_name github_${{ matrix.platform }}_tests \
--build_number ${GITHUB_RUN_NUMBER} \
${LOADER_PLATFORM:+"--loader_config" "$LOADER_CONFIG"} \
${LOADER_PLATFORM:+"--loader_platform" "$LOADER_PLATFORM"} \
${DIMENSION:+"--dimension" "$DIMENSION"} \
${USE_SHARDING:+"--unittest_shard_index" "${{ matrix.shard }}"} \
${ON_DEVICE_TEST_ATTEMPTS:+"--test_attempts" "$ON_DEVICE_TEST_ATTEMPTS"} \
--archive_path gs://${PROJECT_NAME}-test-artifacts/${WORKFLOW}/${GITHUB_RUN_NUMBER}/${{ matrix.platform }}_${{ matrix.config }}/artifacts.tar \
--label github \
--label ${GITHUB_EVENT_NAME} \
--label ${WORKFLOW} \
--label actor-${GITHUB_ACTOR} \
--label actor_id-${GITHUB_ACTOR_ID} \
--label triggering_actor-${GITHUB_TRIGGERING_ACTOR} \
--label sha-${GITHUB_SHA} \
--label repository-${GITHUB_REPO} \
--label author-${GITHUB_PR_HEAD_USER_LOGIN:-$GITHUB_COMMIT_AUTHOR_USERNAME} \
--label author_id-${GITHUB_PR_HEAD_USER_ID:-$GITHUB_COMMIT_AUTHOR_EMAIL}
shell: bash
1 change: 1 addition & 0 deletions .github/config/win32.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"docker_service": "build-win-win32",
"docker_runner_service": "runner-win-win32",
"runner_tag": "win32",
"platforms": [
"win32"
],
Expand Down
19 changes: 19 additions & 0 deletions .github/config/xb1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"docker_service": "build-xb1",
"__comment" : "TODO: Deploy a runner and change this",
"docker_runner_service": "runner-xb1",
"runner_tag": "xb1",
"platforms": [
"xb1"
],
"includes": [
{
"name":"xb1",
"platform":"xb1",
"target_platform":"xb1",
"extra_gn_arguments": "is_clang=false",
"target_cpu": "target_cpu=\\\"x64\\\"",
"target_os": "target_os=\\\"winuwp\\\""
}
]
}
10 changes: 8 additions & 2 deletions .github/workflows/main_win.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ jobs:
run: |
docker_runner_service=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -rc '.docker_runner_service')
echo "docker_runner_service=${docker_runner_service}" >> $GITHUB_ENV
- id: set-runner-tag
shell: bash
run: |
runner_tag=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -rc '.runner_tag')
echo "runner_tag=${runner_tag}" >> $GITHUB_ENV
outputs:
platforms: ${{ env.platforms }}
includes: ${{ env.includes }}
Expand All @@ -120,6 +125,7 @@ jobs:
on_host_test_shards: ${{ env.on_host_test_shards }}
docker_service: ${{ env.docker_service }}
docker_runner_service: ${{ env.docker_runner_service }}
runner_tag: ${{ env.runner_tag }}
# Build windows docker images.
build-docker-image:
needs: [initialize]
Expand Down Expand Up @@ -152,7 +158,7 @@ jobs:
build:
needs: [initialize]
permissions: {}
runs-on: [self-hosted, win32]
runs-on: [self-hosted, "${{ needs.initialize.outputs.runner_tag }}"]
name: ${{matrix.name}}_${{matrix.config}}
strategy:
fail-fast: false
Expand Down Expand Up @@ -186,7 +192,7 @@ jobs:
needs: [initialize, build]
permissions: {}
if: needs.initialize.outputs.on_host_test == 'true'
runs-on: [self-hosted, win32]
runs-on: [self-hosted, "${{ needs.initialize.outputs.runner_tag }}"]
name: ${{matrix.name}}_${{matrix.shard}}_test
strategy:
fail-fast: false
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/xb1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: xb1

on:
pull_request:
types: [opened, reopened, synchronize, labeled]
branches:
- main
- feature/*
push:
branches:
- main
- feature/*
schedule:
# GTM timezone.
- cron: '0 4 * * *'
workflow_dispatch:
inputs:
nightly:
description: 'Nightly workflow.'
required: true
type: boolean
default: false

jobs:
xb1:
uses: ./.github/workflows/main_win.yaml
permissions:
packages: write
pull-requests: write
with:
platform: xb1
nightly: ${{ github.event.inputs.nightly }}
11 changes: 10 additions & 1 deletion base/files/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ File::File(File&& other)
tracing_path_(other.tracing_path_),
error_details_(other.error_details()),
created_(other.created()),
async_(other.async_) {}
async_(other.async_)
#if defined(STARBOARD)
,
append_(other.append_)
#endif
{
}

File::~File() {
// Go through the AssertIOAllowed logic.
Expand All @@ -78,6 +84,9 @@ File& File::operator=(File&& other) {
error_details_ = other.error_details();
created_ = other.created();
async_ = other.async_;
#if defined(STARBOARD)
append_ = other.append_;
#endif
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion base/files/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class BASE_EXPORT File {
bool async_;

#if defined(STARBOARD)
bool append_;
bool append_ = false;
#endif

DISALLOW_COPY_AND_ASSIGN(File);
Expand Down
7 changes: 4 additions & 3 deletions base/files/file_util_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <stack>
#include <string>
#include <sys/stat.h>

#include "base/base_paths.h"
#include "base/files/file_enumerator.h"
Expand Down Expand Up @@ -317,7 +318,8 @@ bool CreateDirectoryAndGetError(const FilePath &full_path, File::Error* error) {

// Fast-path: can the full path be resolved from the full path?
if (DirectoryExists(full_path) ||
SbDirectoryCreate(full_path.value().c_str())) {
mkdir(full_path.value().c_str(), 0700) == 0 ||
SbDirectoryCanOpen(full_path.value().c_str())) {
return true;
}

Expand All @@ -341,8 +343,7 @@ bool CreateDirectoryAndGetError(const FilePath &full_path, File::Error* error) {
if (DirectoryExists(*i)) {
continue;
}

if (!SbDirectoryCreate(i->value().c_str())) {
if (mkdir(i->value().c_str(), 0700) != 0 && !SbDirectoryCanOpen(i->value().c_str())) {
if (error)
*error = File::OSErrorToFileError(SbSystemGetLastError());
return false;
Expand Down
2 changes: 2 additions & 0 deletions cobalt/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ static_library("browser") {
"client_hint_headers.h",
"device_authentication.cc",
"device_authentication.h",
"on_screen_keyboard_extension_bridge.cc",
"on_screen_keyboard_extension_bridge.h",
"on_screen_keyboard_starboard_bridge.cc",
"on_screen_keyboard_starboard_bridge.h",
"render_tree_combiner.cc",
Expand Down
63 changes: 57 additions & 6 deletions cobalt/browser/browser_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include <map>
#include <memory>
#include <utility>
#include <vector>

#include "base/bind.h"
Expand All @@ -35,6 +36,7 @@
#include "cobalt/base/init_cobalt.h"
#include "cobalt/base/source_location.h"
#include "cobalt/base/tokens.h"
#include "cobalt/browser/on_screen_keyboard_extension_bridge.h"
#include "cobalt/browser/on_screen_keyboard_starboard_bridge.h"
#include "cobalt/browser/screen_shot_writer.h"
#include "cobalt/browser/switches.h"
Expand Down Expand Up @@ -142,6 +144,16 @@ const char kFuzzerToggleCommandLongHelp[] =
"activated or not. While activated, input will constantly and randomly be "
"generated and passed directly into the main web module.";

#if defined(ENABLE_DEBUGGER)
// Command to reload the current URL.
const char kBoxDumpCommand[] = "boxdump";

// Help strings for the navigate command.
const char kBoxDumpCommandShortHelp[] = "Return a box dump.";
const char kBoxDumpCommandLongHelp[] =
"Returns a dump of the most recent layout box tree.";
#endif

const char kScreenshotCommand[] = "screenshot";
const char kScreenshotCommandShortHelp[] = "Takes a screenshot.";
const char kScreenshotCommandLongHelp[] =
Expand Down Expand Up @@ -237,12 +249,6 @@ BrowserModule::BrowserModule(const GURL& url,
updater_module_(updater_module),
#endif
splash_screen_cache_(new SplashScreenCache()),
on_screen_keyboard_bridge_(
OnScreenKeyboardStarboardBridge::IsSupported() &&
options.enable_on_screen_keyboard
? new OnScreenKeyboardStarboardBridge(base::Bind(
&BrowserModule::GetSbWindow, base::Unretained(this)))
: NULL),
web_module_loaded_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
web_module_created_callback_(options_.web_module_created_callback),
Expand All @@ -263,6 +269,12 @@ BrowserModule::BrowserModule(const GURL& url,
kFuzzerToggleCommand,
base::Bind(&BrowserModule::OnFuzzerToggle, base::Unretained(this)),
kFuzzerToggleCommandShortHelp, kFuzzerToggleCommandLongHelp)),
#if defined(ENABLE_DEBUGGER)
ALLOW_THIS_IN_INITIALIZER_LIST(boxdump_command_handler_(
kBoxDumpCommand,
base::Bind(&BrowserModule::OnBoxDumpMessage, base::Unretained(this)),
kBoxDumpCommandShortHelp, kBoxDumpCommandLongHelp)),
#endif // defined(ENABLE_DEBUGGER)
ALLOW_THIS_IN_INITIALIZER_LIST(screenshot_command_handler_(
kScreenshotCommand,
base::Bind(&OnScreenshotMessage, base::Unretained(this)),
Expand Down Expand Up @@ -294,6 +306,28 @@ BrowserModule::BrowserModule(const GURL& url,
current_main_web_module_timeline_id_(-1) {
TRACE_EVENT0("cobalt::browser", "BrowserModule::BrowserModule()");

if (options.enable_on_screen_keyboard) {
if (OnScreenKeyboardExtensionBridge::IsSupported()) {
const CobaltExtensionOnScreenKeyboardApi* on_screen_keyboard_extension =
static_cast<const CobaltExtensionOnScreenKeyboardApi*>(
SbSystemGetExtension(kCobaltExtensionOnScreenKeyboardName));
on_screen_keyboard_bridge_ =
std::make_unique<OnScreenKeyboardExtensionBridge>(
base::Bind(&BrowserModule::GetSbWindow, base::Unretained(this)),
on_screen_keyboard_extension);
} else {
if (OnScreenKeyboardStarboardBridge::IsSupported()) {
on_screen_keyboard_bridge_ =
std::make_unique<OnScreenKeyboardStarboardBridge>(base::Bind(
&BrowserModule::GetSbWindow, base::Unretained(this)));
} else {
on_screen_keyboard_bridge_ = NULL;
}
}
} else {
on_screen_keyboard_bridge_ = NULL;
}

// Apply platform memory setting adjustments and defaults.
ApplyAutoMemSettings();

Expand Down Expand Up @@ -789,6 +823,13 @@ void BrowserModule::RequestScreenshotToFile(
const base::Optional<math::Rect>& clip_rect,
const base::Closure& done_callback) {
TRACE_EVENT0("cobalt::browser", "BrowserModule::RequestScreenshotToFile()");
if (!self_message_loop_->task_runner()->BelongsToCurrentThread()) {
self_message_loop_->task_runner()->PostTask(
FROM_HERE, base::Bind(&BrowserModule::RequestScreenshotToFile,
base::Unretained(this), path, image_format,
clip_rect, std::move(done_callback)));
return;
}
DCHECK_EQ(base::MessageLoop::current(), self_message_loop_);
EnsureScreenShotWriter();
DCHECK(screen_shot_writer_);
Expand Down Expand Up @@ -2222,5 +2263,15 @@ void BrowserModule::ValidateCacheBackendSettings() {
network_module_->url_request_context()->ValidateCachePersistentSettings();
}

#if defined(ENABLE_DEBUGGER)
std::string BrowserModule::OnBoxDumpMessage(const std::string& message) {
std::string response = "No MainWebModule.";
if (web_module_) {
response = web_module_->OnBoxDumpMessage(message);
}
return response;
}
#endif

} // namespace browser
} // namespace cobalt
9 changes: 9 additions & 0 deletions cobalt/browser/browser_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ class BrowserModule {
// Pass the deeplink timestamp from Starboard.
void SetDeepLinkTimestamp(int64_t timestamp);

#if defined(ENABLE_DEBUGGER)
std::string OnBoxDumpMessage(const std::string& message);
#endif // ENABLE_DEBUGGER

private:
// Called when the WebModule's Window.onload event is fired.
void OnLoad();
Expand Down Expand Up @@ -646,6 +650,11 @@ class BrowserModule {
// Command handler object for toggling the input fuzzer on/off.
debug::console::ConsoleCommandManager::CommandHandler
fuzzer_toggle_command_handler_;
#if defined(ENABLE_DEBUGGER)
// Command handler object for boxdump command from the debug console.
debug::console::ConsoleCommandManager::CommandHandler
boxdump_command_handler_;
#endif

// Command handler object for screenshot command from the debug console.
debug::console::ConsoleCommandManager::CommandHandler
Expand Down
Loading

0 comments on commit b1a7d3e

Please sign in to comment.