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 performance of cosmetic filters #12950

Merged
merged 2 commits into from
Apr 12, 2022

Conversation

atuchin-m
Copy link
Collaborator

@atuchin-m atuchin-m commented Apr 8, 2022

For brave/brave-browser#22030
1.37.5 => good
image (13)

1.37.6 => bad
image (12)

Try to revert #12038 that makes cosmetic filters slower.

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • 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)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • 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:

See brave/brave-browser#22030 (comment)

@github-actions github-actions bot added the CI/storybook-url Deploy storybook and provide a unique URL for each build label Apr 8, 2022
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@SergeyZhukovsky
Copy link
Member

@atuchin-m nice find. Need perhaps to polish and profile more what @antonok-edm did before we can re-merge it back.

@SergeyZhukovsky
Copy link
Member

we have also reports on Android that 1.37.x is slower comparing to 1.36.x

Copy link
Member

@SergeyZhukovsky SergeyZhukovsky left a comment

Choose a reason for hiding this comment

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

need to fix a few tests before merge, but otherwise looks good

@@ -2158,7 +2153,6 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, CosmeticFilteringIframeScriptlet) {
ASSERT_EQ(true, EvalJs(contents, "show_ad"));
}

<<<<<<< HEAD
// Test cosmetic filtering on an element that already has an `!important`
// marker on its `display` style.
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
Copy link
Collaborator

Choose a reason for hiding this comment

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

AdBlockServiceTest.CosmeticFilteringOverridesImportant will have to be disabled as well, that was the primary issue fixed by the original PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@antonok-edm also CosmeticFilteringDynamicCustom doesn't work. Is it expected?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, unfortunately it looks like I inserted two different fixes into the same PR. If you un-revert the changes in CosmeticFilteringDynamicCustom and in test/data/cosmetic_filtering.html, I think that one should work fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In fact it's not enough..

[55080:56304:0411/175238.315:INFO:CONSOLE(5)] "still waiting for css selector", source: __const_std::string&_script__ (5)
content/public/test/browser_test_utils.cc(2659): error: Failed
RunLoop::Run() timed out. Timeout set at ProxyRunTestOnMainThreadLoop@content/public/test/browser_test_base.cc:809.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just pushed a couple of fixes for that as well.

@antonok-edm antonok-edm force-pushed the fix-performance-of-cosmetic-filters branch from fff2121 to b8190f6 Compare April 11, 2022 23:02
@antonok-edm antonok-edm force-pushed the fix-performance-of-cosmetic-filters branch from b8190f6 to ad53d05 Compare April 11, 2022 23:03
@antonok-edm antonok-edm added this to the 1.37.x - Release #5 milestone Apr 11, 2022
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@antonok-edm
Copy link
Collaborator

macOS CI failures are known/unrelated

@antonok-edm antonok-edm merged commit 2b7592b into master Apr 12, 2022
@antonok-edm antonok-edm deleted the fix-performance-of-cosmetic-filters branch April 12, 2022 00:54
brave-builds pushed a commit that referenced this pull request Apr 12, 2022
brave-builds pushed a commit that referenced this pull request Apr 12, 2022
@kjozwiak
Copy link
Member

kjozwiak commented Apr 12, 2022

Reproduced the original issue on Win 11 x64 using the STR/Cases outlined via brave/brave-browser#22030 (comment) with the following build:

Brave | 1.39.47 Chromium: 100.0.4896.79 (Official Build) nightly (64-bit)
-- | --
Revision | 8fb749dcab8700c24213791969e59deb72fee36f-refs/branch-heads/4896@{#1015}
OS | Windows 11 Version 21H2 (Build 22000.593)
  • Shields disabled - ~250ms - 300ms
  • Shields enabled - ~850ms - 1s
Shields Disabled Shields Enabled
withoutShieldEnabled withShieldsEnabled

Verification PASSED on Win 11 x64 using the following build(s):

Brave | 1.39.52 Chromium: 100.0.4896.88 (Official Build) nightly (64-bit)
-- | --
Revision | 4450653bfa91182e85723d8f1dee64dd6ce40ed4-refs/branch-heads/4896@{#1086}
OS | Windows 11 Version 21H2 (Build 22000.593)
  • Shields disabled - ~250ms - 300ms
  • Shields enabled - ~300ms - 385ms
Shields Disabled Shields Enabled
fixedDisabled fixedEnabled

@atuchin-m
Copy link
Collaborator Author

It should be >=1.39.49, 48 doesn't have the fix:
image

@kjozwiak
Copy link
Member

It should be >=1.39.49, 48 doesn't have the fix: image

yup, used 1.39.52 Chromium: 100.0.4896.88 👍 It was technically supposed to be in 1.39.48 but looks like that used to basically bump the tags. Finished verifying and updated the above notes.

antonok-edm added a commit that referenced this pull request Apr 19, 2022
…tic-filters"

This reverts commit 2b7592b, reversing
changes made to f71c815.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/storybook-url Deploy storybook and provide a unique URL for each build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants