media/ffmpeg/scripts/robosushi.md
Greetings, Adventurer!
The Chrome Videostack team uses the open source FFmpeg project for various decoding / demuxing tasks. We maintain a local copy of FFmpeg within the chromium tree (//third_party/ffmpeg) that we keep reasonably up-to-date with the FFmpeg project. This document describes how to do the "FFmpeg roll", which is the process by which we import new versions of FFmpeg into Chromium.
"Robosushi" refers to the tool that we use to automatically merge new changes from the FFmpeg maintainers into our local copy, build generated files, run tests, and manage the review process.
This document assumes that you are the current FFmpeg roller. We'll describe how you do that with robosushi, what the scripts are doing, and what to do if things don't work right.
Please contribute to this doc, the FFmpeg roll process, and to the scripts!
This tool is only kept alive by the loving efforts of the Video Stack team. When you find something that bothers you, fix it, or ask about it.
There are generally three sources of problems when updating Chromium's copy of FFmpeg: local changes, unwanted upstream code, and test failures.
The FFmpeg roller has to sort these out.
Historically, FFmpeg rolls were labor-intensive, and happened only once per Chromium milestone. We'd like to reduce that because:
Therefore, it's in our interest to roll ffmpeg early and often.
While the roll is still a manual process, the robosushi scripts are written with the intention of moving us as close to regular, automatic rolls as we can. Please consider improving them!
Before running the scripts, it is helpful to understand how Chromium (which uses GN) builds FFmpeg (which uses shell scripts and Makefiles).
Chromium uses .gn files to build everything. FFmpeg uses a configure script.
To get these two to work together, robosushi performs the following dance:
configure script for every supported
platform/architecture combination (Linux, ARM, etc.)..o files to determine exactly which
source files were used.BUILD.gn files
that Chromium uses.This logic is handled by build_ffmpeg.py (builds locally) and generate_gn.py
(creates GN files). Crucially, if you only build for one platform (your
host), the GN files for other platforms will be incorrect. Robosushi handles
building all configurations automatically.
The //third_party/ffmpeg repo is separate from Chromium. The DEPS file in
Chromium points to a specific commit hash in the FFmpeg repo.
third_party/ffmpeg.third_party/ffmpeg.DEPS file to point to your new
commit. Until this step, your changes do not affect the rest of Chromium.We do it that way because if you git cl upload a merge commit that brings in
thousands of upstream commits, Gerrit may interpret all those authors as active
participants in your CL and add them to the CC list. This spams the entire
FFmpeg community.
Respecting this pattern is probably the most important step you can take while doing a roll.
Our developer relationship with FFmpeg is very important and this specific issue has occurred in the past.
When merging from upstream, we have two goals. First, we want to git push
(not git cl upload) the merge commit itself to a merge branch in origin.
Note that patch fixes you add manually (e.g. as part of fixing a Fuzzer bug) can
be safely uploaded using git cl upload.
Robosushi handles this automatically. It pushes the merge to origin
immediately using git push (bypassing Gerrit) and sets your local branch to
track it. This ensures that when git cl upload runs later for your config
changes, it sees the upstream history as "already known" and only uploads your
specific changes.
The Robosushi tool assumes that you are running an x64 Linux machine!
The tool currently supports installing needed packages on Debian and Arch Linux distributions. Some limited support for other Linux-ish platforms, like Cygwin on Windows, is present but has not been tested recently and may not work. You may need to update robo_lib/packages.py if using a different package manager.
Run this command once to install packages and toolchains:
cd /path/to/chromium/src
./media/ffmpeg/scripts/robosushi.py --setup
auto-merge./media/ffmpeg/scripts/robosushi.py --auto-merge [--prompt]
This command runs the full pipeline. The --prompt option is recommended if you
want to approve each step (merging, building, uploading).
If the full pipeline succeeds, you may be able to just move to the next step.
Otherwise, check the logs outputted to media/ffmpeg/scripts/robosushi.log and
then jump to the
Troubleshooting Common Failures
section.
git diff origin/master configure | grep '^.*\[autodetect\]' in the CL description or comments to help reviewers
check for accidental feature enablement.robosushi.py --auto-merge one last time.
origin/sushi-BRANCH to origin/master.*san (ASAN, MSAN, etc.) bots to the
DEPS roll CQ to ensure memory safety.Robosushi outputs all logs to //media/ffmpeg/scripts/robosushi.log.
This is usually a good place to start when diagnosing issues.
If robosushi stops and tells you there are conflicts:
//third_party/ffmpeg.// Chrome: comment
explaining why. This helps future rollers.robosushi.py --auto-merge again.If the script fails to upload to Gerrit, verify you are a member of the Chrome Committers group.
If media_unittests or ffmpeg_regression_tests fail:
robosushi.py --auto-merge again../media/ffmpeg/scripts/robosushi.py --auto-merge --force-gn-rebuildREADME.chromium - This file tracks the upstream SHA1 and merge dates. Robosushi updates this automatically.
During a merge conflict, it can be helpful to see the original patch that modified a file to understand the intent of the local change.
To see the history of a file in the current branch (Chromium's copy):
git log HEAD -- path/to/file
You can then inspect specific commits to see the original patch:
git show <commit_hash>
To see the version of the file from the upstream branch you are merging:
git show MERGE_HEAD:path/to/file
To see the common ancestor (what the file looked like before both sides diverged):
git show $(git merge-base HEAD MERGE_HEAD):path/to/file
If robosushi is acting up, or if you simply want to understand the magic, here
is what is happening under the hood.
sushi-DATE branch is created from origin/master.upstream/master is merged into the sushi branch.origin/sushi-DATE
without review.
git push origin sushi-DATEgit branch --set-upstream-to=origin/sushi-DATEgit cl upload from seeing the upstream history as "new".build_ffmpeg.py configures and builds FFmpeg for all architectures
(Linux, ARM, etc.).generate_gn.py scans the build artifacts to create BUILD.gn files.check_merge.py verifies licenses and bad files.media_unittests and ffmpeg_regression_tests are compiled and
run.git cl upload sends the GN config changes and patches for
review.origin/master.origin/master tip.The parent tracking issue for FFmpeg rolls in Chromium is publicly viewable at crbug.com/450394703: FFmpeg Rolls In Chromium, and should be the parent for all FFmpeg roll-related issues in the Chromium project.
Some issues are tracked more directly in crbug.com/466458817: Rolling third_party/ffmpeg is unpleasant.
If you experience a new issue while performing the roll, please file an issue (and fix it if you can!).