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

Fix failing component auto-updates #7164

Merged
merged 6 commits into from
Jan 7, 2021

Conversation

mherrmann
Copy link
Collaborator

@mherrmann mherrmann commented Nov 17, 2020

Resolves brave/brave-browser#10464
Also resolves brave/brave-browser#10280

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:

@mherrmann mherrmann added CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS labels Nov 17, 2020
@mherrmann mherrmann requested a review from a team as a code owner November 17, 2020 07:42
@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch 3 times, most recently from 33d7834 to 6c7be95 Compare November 17, 2020 18:28
@mherrmann
Copy link
Collaborator Author

@jumde the implementation is complete from my side. Can you review, or can you suggest someone else to review? (It's only my second PR to brave-core.)

@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch 2 times, most recently from c309d11 to 18555cd Compare November 20, 2020 17:20
@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch 2 times, most recently from 540bb4a to c4dd298 Compare November 23, 2020 19:38
@mherrmann mherrmann added the CI/skip-macos-x64 Do not run CI builds for macOS x64 label Nov 24, 2020
@mherrmann
Copy link
Collaborator Author

@jumde just so it's visible here too, instead of hidden in the review conversation: the PR is ready to merge from my side (excl. squash, rebase and potentially removing log statements). I'd kindly ask that you review please and let me know what you think.

@mherrmann mherrmann changed the title WIP: Fix failing component auto-updates Fix failing component auto-updates Nov 25, 2020
@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch from 50e468d to 1533918 Compare November 25, 2020 06:48
@mherrmann
Copy link
Collaborator Author

mherrmann commented Nov 25, 2020

@mkarolin @bridiver can I also request your review on this? (@jumde suggested I ask you.) The short summary is: When you open brave://components and wait for 1 minute, then you see a bunch of update errors on the page. The reason for this is explained in the comment in my committed file update_checker.h. This is only my second PR to brave-core, so I would love to hear your thoughts.

(edit: I accidentally tagged @pes10k as reviewer at first)

@jumde
Copy link
Contributor

jumde commented Nov 25, 2020

@mherrmann - This fix also installs components (during auto-update) that shouldn't be shipped with Brave like Federated Learning Of Cohorts, Legacy TLS Deprecation Configuration, Subresource FIlter Rules. Only the components that are installed at the first run, should be updated with auto-update.

@jumde jumde added the CI/run-network-audit Run network-audit label Nov 25, 2020
@mherrmann
Copy link
Collaborator Author

@jumde do you have an idea why those components are being installed?

@jumde
Copy link
Contributor

jumde commented Nov 25, 2020

@jumde do you have an idea why those components are being installed?

@mherrmann - I need to dig into the chromium code to see why this might be happening.

@mherrmann
Copy link
Collaborator Author

Okay, thank you. As a workaround, could we make go-update return "no update" responses for those components we do not wish to be installed?

@jumde
Copy link
Contributor

jumde commented Nov 25, 2020

Okay, thank you. As a workaround, could we make go-update return "no update" responses for those components we do not wish to be installed?

I think it would be easy to fix this on brave-core. If we do it on go-update, this will require updating go-update every time a component is added to the chromium code and it adds a testing burden as well.

@mherrmann
Copy link
Collaborator Author

I think it would be easy to fix this on brave-core. If we do it on go-update, this will require updating go-update every time a component is added to the chromium code and it adds a testing burden as well.

Ah, I see. That makes sense. Thank you. I'm very curious what you'll find about those additionally installed components.

@mherrmann
Copy link
Collaborator Author

mherrmann commented Nov 26, 2020

@jumde I develop on Linux. I just started Brave Nightly v1.19.36 on a Windows VM I haven't touched in a month. I have the components you mentioned also on this Windows VM:

image

You wrote that my PR here installs these unwanted components. Do I presume correctly that you actually meant that my PR updates these components, possibly from a non-existent skeleton implementation?

I'll dig a little further how these components get there in the first place.

@mherrmann
Copy link
Collaborator Author

mherrmann commented Nov 26, 2020

After some further digging, I have a better understanding how components are installed. Chromium installs its components in chrome/browser/component_updater/registration.cc. This is called from chrome_browser_main.cc in ChromeBrowserMainParts::PreMainMessageLoopRunImpl. Brave has a subclass BraveBrowserMainParts of ChromeBrowserMainParts that however does not override PreMainMessageLoopRunImpl.

What I don't understand is that apparently there is a wish to exclude certain Google components from being shipped with Brave. But besides some extra Brave components, my components in Chrome and Brave are basically the same.

The closest thing I could find to an implementation is IsBlacklisted in brave-core, which gets invoked from UserMayLoad. However, the associated classes refer to extensions, not components. I'm not sure yet whether that logic is then also used for components. Also potentially related: ExtensionInstallBlacklist on chrome://policy. If that blacklist applies to components as well as extensions, then we might be able to use it.

@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch from 1533918 to ac3e1f6 Compare November 26, 2020 19:10
@mherrmann
Copy link
Collaborator Author

mherrmann commented Nov 27, 2020

@jumde kindly pointed me to https://github.com/brave/brave-browser/wiki/Brave-Components, which lists the components officially supported by Brave, and those officially unsupported.

What surprises me is that my local Brave installation has many of the components that are supposed to be unsupported. For example, "Certificate Error Assistant" and "Crowd Deny".

@jumde also pointed out that components can be excluded from Brave by overriding their Register... methods. For example, RegisterSafetyTipsComponent. This fits with my analysis of registration.cc above. Brave does override some such registration functions in brave-core/chromium_src/chrome/browser/component_updater. However, as far as I can see, it does not actually stop any components from being installed.

Coming back to this PR: It doesn't seem to me like it installs any components that shouldn't be there. But yes, it does update all components, including the unwanted ones.

If updating unwanted components is a problem, then this PR shouldn't be merged yet and we have to prevent the components from being there in the first place. Otherwise, I would tackle removing these unwanted components in the separate existing issue brave/brave-browser#8709.

@jumde do you see an issue with merging this PR and tackling brave/brave-browser#8709 separately?

@mherrmann
Copy link
Collaborator Author

After reading brave/brave-browser#10607 (comment), I think I can answer my question myself. It probably would be a problem to merge this PR. The reason is that while Brave does not prevent Chromium from registering unwanted components, it does not install them. My suspicion is that Chromium installs components by registering them with version 0.0.0.0, then performing an automatic update check. In Brave, this automatic update check was previously broken (hence the present PR). Hence the components were not installed.

So yes, I do think that we should tackle brave/brave-browser#8709 before merging this PR.

@mihaiplesa mihaiplesa requested a review from bridiver December 17, 2020 11:32
@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch from e74d017 to 9661d35 Compare December 28, 2020 17:57
@mherrmann
Copy link
Collaborator Author

mherrmann commented Dec 29, 2020

Tested the latest CI build for this PR on Linux (brave-browser-nightly_1.20.47_amd64.deb). Works as expected for me. After 60 seconds on brave://components, I see:

image

Note how there are no update errors.

The only question mark is the new "Hyphenation" component. It seems this was introduced in a recent Chromium version. If Brave does not want to include it, then we should block it as in #7331.

@mihaiplesa mihaiplesa added CI/skip-android Do not run CI builds for Android CI/skip-linux labels Dec 29, 2020
Copy link
Collaborator

@mihaiplesa mihaiplesa left a comment

Choose a reason for hiding this comment

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

Tested on macOS and works as expected. CI passed on all.

@mihaiplesa mihaiplesa requested a review from simonhong December 29, 2020 18:06
@simonhong simonhong mentioned this pull request Jan 5, 2021
23 tasks
@simonhong
Copy link
Member

Kindly ping to @brave/patch-reviewers :)

@mihaiplesa
Copy link
Collaborator

mihaiplesa commented Jan 5, 2021

@bridiver said this looks fine, just waiting for @jumde's latest thoughts.

Copy link
Contributor

@jumde jumde left a comment

Choose a reason for hiding this comment

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

lgtm

@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch from ec48aed to 76e4eeb Compare January 6, 2021 08:58
@mherrmann
Copy link
Collaborator Author

I rebased onto master and force-pushed to get a CI build one last time before merging.

@mherrmann
Copy link
Collaborator Author

mherrmann commented Jan 6, 2021

The post-init check fails because of what I believe is a bug in lint.py

/home/ubuntu/workspace/pr-brave-browser-mherrmann-fix-google-components-autoupdate-post-init/src
10:07:48  > ninja -C /home/ubuntu/workspace/pr-brave-browser-mherrmann-fix-google-components-autoupdate-post-init/src/out/Component_audit brave:audit_deps
10:07:48  ninja: Entering directory `/home/ubuntu/workspace/pr-brave-browser-mherrmann-fix-google-components-autoupdate-post-init/src/out/Component_audit'
10:07:50  Error running format check:
10:07:50  Traceback (most recent call last):
10:07:50    File "/home/ubuntu/workspace/pr-brave-browser-mherrmann-fix-google-components-autoupdate-post-init/src/brave/build/commands/scripts/lint.py", line 35, in RunFormatCheck
10:07:50      if HasFormatErrors():
10:07:50    File "/home/ubuntu/workspace/pr-brave-browser-mherrmann-fix-google-components-autoupdate-post-init/src/brave/build/commands/scripts/lint.py", line 26, in HasFormatErrors
10:07:50      print(diff)
10:07:50  UnicodeEncodeError: 'ascii' codec can't encode characters in position 265353-265360: ordinal not in range(128)

The person who recently committed the print(diff) line has been alerted. @mihaiplesa is also looking into this.

@mherrmann mherrmann force-pushed the mherrmann-fix-google-components-autoupdate branch from 76e4eeb to acd15a0 Compare January 6, 2021 17:54
@mherrmann
Copy link
Collaborator Author

The post-init check succeeded now. I also tested the CI build on Linux and am getting the expected result. On brave://components, after 60 seconds, an automatic update check is performed and no more errors appear:

image

Merging this.

@mherrmann
Copy link
Collaborator Author

@bridiver or @mkarolin can I get your approval on this PR please? I can't merge without another (4th) approving review.

image

image

@mihaiplesa
Copy link
Collaborator

Merging as the last change was minor.

@mihaiplesa mihaiplesa merged commit 968c5c5 into master Jan 7, 2021
@mihaiplesa mihaiplesa deleted the mherrmann-fix-google-components-autoupdate branch January 7, 2021 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-network-audit Run network-audit CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google components automatic update fails Fix crowd-deny updates
6 participants