-
Notifications
You must be signed in to change notification settings - Fork 871
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
procedural filtering #24688
procedural filtering #24688
Conversation
bdcdf39
to
802bf11
Compare
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
d31ba6a
to
b4c8b5f
Compare
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
8881250
to
de95d87
Compare
A Storybook has been deployed to preview UI for the latest push |
de95d87
to
f5ba907
Compare
A Storybook has been deployed to preview UI for the latest push |
f5ba907
to
6da2aa6
Compare
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
1d3a3c3
to
7a7b371
Compare
fed2070
to
ae695ee
Compare
// These filters are represented as JSON provided by adblock-rust. The format | ||
// is documented at: | ||
// https://docs.rs/adblock/latest/adblock/cosmetic_filter_cache/struct.ProceduralOrActionFilter.html | ||
void StripProceduralFilters(base::Value::Dict& resources) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in a separate helper file? If this is just for testing, you should add a friend test so it can be a private method in the adblock service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or is this to make it accessible to ios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have two other unit-tested helper methods in there too, seemed like it fit with those.
I don't think we have a mockable version of AdBlockService
just yet, moving it there would mean we need to use browsertests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is fine for now, but I'm not a fan of exposing these as public methods. Can we at least move it into an internal
target and restrict visibility? This should ideally be the case with any classes that shouldn't be used outside the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
[puLL-Merge] - brave/brave-core@24688 DescriptionThis PR introduces support for procedural cosmetic filtering in Brave's ad-blocking engine. It updates the adblock Rust library from version 0.8.12 to 0.9.0 and adds new functionality to handle procedural filters like ChangesChanges
Possible Issues
Security Hotspots
Overall, this PR significantly enhances Brave's ad-blocking capabilities but introduces complexity that requires careful testing and security review, especially around the new JavaScript-based procedural filtering logic. |
757454e
to
bfa38f0
Compare
bfa38f0
to
5f555c9
Compare
@@ -9,6 +9,8 @@ | |||
// - for cosmetic filters work with CSS and stylesheet. That work itself | |||
// could call the script several times. | |||
|
|||
import { applyCompiledSelector, compileProceduralSelector } from './procedural_filters' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antonok-edm @bridiver
This results in significant increasing the JS inject size to every frame.
I hope you estimated the extra loading delay somehow. Could you share the numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atuchin-m to make sure I understand, there's an increase in load times? Does that happen on every page, or only pages with an active filter rule that uses a procedural filter? And does it happen in Standard mode, or also Aggressive mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShivanKaul
It add an overhead to any page load (we always inject the script if Shields aren't down)
The script size changed in 2x times:
I don't see any major changes in high-level metrics on the dashboard now, but every such change (+10k JS inject) makes Brave harder to compete against Chrome.
Resolves brave/brave-browser#16935
Please see self-review notes here before reviewing!
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
brave://settings/shields/filters
, subscribe to https://antonok.com/tmp/procedural-filter-tests/test-extended-css-rules.txt.Test notes
The tests are from https://testcases.agrd.dev/Filters/extended-css-rules/test-extended-css-rules, with slight modifications to disable autostart. Autostart must be disabled because Brave executes some cosmetic filters with batched operations for performance reasons. The test code runs immediately and synchronously, but those batched operations can occur after the page test logic already declares the tests failed.
Other failures on the test page are expected. Many of the test cases use AdGuard-specific syntax extensions or other features that are not currently supported by this initial implementation - we'll get to those in some followups 😄