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

Use widevine component on linux #7228

Merged
merged 5 commits into from
Dec 4, 2020
Merged

Use widevine component on linux #7228

merged 5 commits into from
Dec 4, 2020

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Nov 23, 2020

So far, we've been using our own widevine downloader because chromium on linux didn't support it via component.
At that time, chrome also only used bundled widevine.
But, chromium started to support to get widevine with component. So, we don't need to use our module for fetching widevine.

If enable_widevine is enabled, enable_widevine_cdm_component is turned on by default for non-google-chrome branding.
So, we don't need to touch widevine.gni anymore.

Resolves brave/brave-browser#7081
Resolves brave/brave-browser#7831
Resolves brave/brave-browser#3955

Test scenario:

Test with clean profile

  1. Launch browser with clean profile
  2. Check widevine is not available from brave://components
  3. Load netflix and agree for installing widevine
  4. Check widevine is available from brave://components
  5. Relaunch browser and check netflix works.

Test with old profile(widevine enabled)

  1. Launch browser
  2. Check widevine is available from brave://components and it's version is 4.10.1610.0
  3. Load netflix and check netflix works
  4. Relaunch browser and load netflix and check netflix works

Test case

npm run test brave_unit_tests -- --filter=*Widevine*
npm run test brave_browser_tests --filter=*Widevine*

Submitter Checklist:

  • There is a ticket for my issue.
  • Used Github auto-closing keywords in the commit message.
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed).
  • Requested a security/privacy review as needed.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

npm run test brave_unit_tests -- --filter=WidevineBuildFlag.FlagTest

@simonhong simonhong self-assigned this Nov 23, 2020
@simonhong simonhong force-pushed the widevine_component_linux branch 2 times, most recently from 520f34d to 1754972 Compare November 23, 2020 08:23
@simonhong simonhong changed the title Use widevine component on linux WIP: Use widevine component on linux Nov 23, 2020
@simonhong simonhong marked this pull request as ready for review November 23, 2020 10:02
@simonhong simonhong requested a review from a team as a code owner November 23, 2020 10:02
@simonhong simonhong force-pushed the widevine_component_linux branch 2 times, most recently from 6ef540a to 9df3896 Compare November 23, 2020 11:10
@simonhong simonhong changed the title WIP: Use widevine component on linux Use widevine component on linux Nov 23, 2020
@simonhong simonhong force-pushed the widevine_component_linux branch 2 times, most recently from e287548 to 6551056 Compare November 23, 2020 11:51
@simonhong simonhong changed the title Use widevine component on linux WIP: Use widevine component on linux Nov 23, 2020
@simonhong simonhong force-pushed the widevine_component_linux branch from 6551056 to e64347b Compare November 23, 2020 12:12
@simonhong
Copy link
Member Author

Hmm, it looks like CI doesn't work well with dedicated b-b branch. will try to run CI again after deleting b-b branch.

# Widevine CDM is bundled as part of Google Chrome builds.
bundle_widevine_cdm = enable_library_widevine_cdm && is_chrome_branded
+bundle_widevine_cdm = enable_library_widevine_cdm && is_desktop_linux
+enable_widevine_cdm_component = enable_library_widevine_cdm && (is_win || is_mac)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will only enable enable_widevine_cdm_component for all desktop platform.

test/BUILD.gn Outdated
"//third_party/widevine/cdm:headers",
]
if (enable_widevine && !is_android) {
sources += [ "//brave/chromium_src/chrome/browser/component_updater/widevine_cdm_component_installer_unittest.cc" ]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move this to separate target.

@simonhong simonhong force-pushed the widevine_component_linux branch from e64347b to aa02219 Compare November 24, 2020 01:39
test/BUILD.gn Outdated
@@ -652,14 +640,17 @@ if (!is_android) {
"//media:test_support",
]

if (enable_widevine && !is_asan) {
if (enable_widevine_cdm_component && !is_asan) {
# Remove the !is_asan check once
# https://github.com/brave/brave-browser/issues/11901 is fixed
sources += [
"//brave/browser/widevine/widevine_permission_request_browsertest.cc",
"//brave/browser/widevine/widevine_prefs_migration_browsertest.cc",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@simonhong simonhong marked this pull request as draft November 25, 2020 03:49
@simonhong simonhong force-pushed the widevine_component_linux branch from aa02219 to d16a5b5 Compare November 25, 2020 03:53
@simonhong simonhong changed the title WIP: Use widevine component on linux Use widevine component on linux Nov 25, 2020
@simonhong simonhong marked this pull request as ready for review November 25, 2020 04:56
@simonhong simonhong force-pushed the widevine_component_linux branch from 83cc26a to 3a59238 Compare November 25, 2020 05:05
@simonhong simonhong requested a review from iefremov November 25, 2020 05:31
@simonhong
Copy link
Member Author

simonhong commented Nov 25, 2020

Ready to review! - Forgot to delete old widevine binaries. Will add cleanup logic -> Done.

@simonhong
Copy link
Member Author

PTAL!

// loaded after re-launching.
void CreateDefaultWidevineCdmHintFile() {
base::FilePath hint_file_path;
CHECK(base::PathService::Get(chrome::FILE_COMPONENT_WIDEVINE_CDM_HINT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure we should kill the browser?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, cdm lib should be loaded during the zygot initialization before sandboxing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's linux-only constraint.

@simonhong simonhong force-pushed the widevine_component_linux branch from eafea07 to c3b9d11 Compare November 29, 2020 00:06
@simonhong simonhong force-pushed the widevine_component_linux branch from c3b9d11 to 9f1824b Compare November 29, 2020 01:10
Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chromium_src/patches changes LGTM

@simonhong simonhong force-pushed the widevine_component_linux branch from 9f1824b to b755b5e Compare December 2, 2020 04:51
@simonhong
Copy link
Member Author

Kindly ping :)

@simonhong simonhong requested a review from kkuehlz December 3, 2020 02:20
@simonhong simonhong force-pushed the widevine_component_linux branch from b755b5e to 4137f21 Compare December 3, 2020 02:39
@@ -22,6 +22,10 @@ class BraveDrmTabHelper final
public brave_drm::mojom::BraveDRM,
public component_updater::ComponentUpdateService::Observer {
public:
// Copied from widevine_cdm_component_installer.cc.
// There is no shared constant value.
static char kWidevineComponentId[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -16,7 +17,8 @@ class WebContents;

class WidevinePermissionRequest : public permissions::PermissionRequest {
public:
explicit WidevinePermissionRequest(content::WebContents* web_contents);
explicit WidevinePermissionRequest(content::WebContents* web_contents,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not explicit now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}
bool DoDeleteOldWidevineBinary() {
base::FilePath widevine_base_path;
CHECK(base::PathService::Get(chrome::DIR_USER_DATA,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly concerned with these CHECKs, since CHECK is for critical situation when the browser just cannot work anymore (i.e. detecting a security breach). Inability to delete the widevine binary (or get a path) doesn't look like a critical problem that prevents the program from working

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Changed to early return if it gives false.

Chromium started to support widevine cdm component since c79.
Before that, only bundling was supported.
So, we've been using our widevine manager for downloading/managing
widevine during the runtime.
With enabling widevine cdm component, all our codes are deleted.
@simonhong simonhong force-pushed the widevine_component_linux branch from 4137f21 to 9a94d62 Compare December 3, 2020 12:14
@simonhong
Copy link
Member Author

Merged because only unrelated lint & gn check were failed and all are fixed by other PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants