-
Notifications
You must be signed in to change notification settings - Fork 901
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
Rewards Extension: delay loading until enabled #3698
Conversation
@@ -78,6 +78,7 @@ source_set("extensions") { | |||
|
|||
if (brave_rewards_enabled) { | |||
deps += [ | |||
"//brave/components/brave_rewards/browser", |
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 believe this is an existing missing dep since brave_rewards_api.cc gets data from the rewards service. However, I also believe there's a circular dependency since there is a class within rewards which fires extension events.
6611baa
to
2cc0fa7
Compare
2cc0fa7
to
6b91526
Compare
return rect.size(); | ||
// Width > Height to give space for a large bubble (especially for shields). | ||
// TODO(petemill): Generate based on toolbar size. | ||
return gfx::Size(34, 24); |
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.
The removed code was actually generating a very incorrect size (height()
here is very small, likely because nothing is making the height of the container fill the height of the toolbar). This explicit size is moved from https://github.com/brave/brave-core/pull/3698/files#diff-469d5e5a21b50831d605cce6cae56765L160
|
||
namespace { | ||
constexpr SkColor kRewardsBadgeBg = SkColorSetRGB(0xfb, 0x54, 0x2b); | ||
const std::string kRewardsInitialBadgeText = "1"; |
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.
Hard-coded string moved from the extension background script, which always ensured that it said "1" until the panel was opened.
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.
Good change 👍
components/brave_rewards/resources/extension/brave_rewards/background/events/rewardsEvents.ts
Outdated
Show resolved
Hide resolved
...brave_rewards/resources/extension/brave_rewards/background/reducers/rewards_panel_reducer.ts
Show resolved
Hide resolved
6b91526
to
84a4825
Compare
ExtensionAction::ActionIconSize(), | ||
ExtensionAction::FallbackIcon().AsImageSkia(), nullptr)); | ||
} | ||
+ BRAVE_GET_EXTENSION_ACTION |
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.
See chromium_src override. This is something that was technically 'broken' with the shields and rewards icons previously, but not noticeable. Now that the extension load happens sometimes after window creation and especially whilst the user is focusing on the button, the jump between image sizes was noticeable.
profile_, &extension, *action->default_icon(), \ | ||
brave_actions::kBraveActionGraphicSize, \ | ||
ExtensionAction::FallbackIcon().AsImageSkia(), nullptr)); \ | ||
} |
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.
See chromium_src override. This is something that was technically 'broken' with the shields and rewards icons previously, but not noticeable. Now that the extension load happens sometimes after window creation and especially whilst the user is focusing on the button, the jump between image sizes was noticeable.
Add(IDR_BRAVE_REWARDS, brave_rewards_path); | ||
} | ||
// Enable rewards extension if already opted-in | ||
HandleRewardsEnabledStatus(); |
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.
nit OnBraveRewardsEnabled
would be more conventional here
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.
@bridiver even if that function handles both enabled and disabled?
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.
there are some issues with this approach (enables rewards extension when clicked even if rewards doesn't get enabled), but @petemill and I have discussed options moving forward so this is fine as a temporary fix
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.
Per comment above we should fetch recurring tip data after enabling, else it looks fine to me.
@ryanml please can you add that or point to the API |
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 pushed the change which fetches recurring tips on enable, all looks good to me nice work!
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.
A lot of browser tests are broken. https://staging.ci.brave.com/job/brave-browser-build-pr/job/rewards-delay-extension/5/execution/node/436/log/
12 tests failed:
02:59:58 BraveRewardsBrowserTest.AutoContribution (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:1715)
02:59:58 BraveRewardsBrowserTest.ClaimGrantViaPanel (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:1601)
02:59:58 BraveRewardsBrowserTest.ContributionWithLowAmount (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:1830)
02:59:58 BraveRewardsBrowserTest.InsufficientNotificationForInsufficientAmount (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2157)
02:59:58 BraveRewardsBrowserTest.InsufficientNotificationForVerifiedInsufficientAmount (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2198)
02:59:58 BraveRewardsBrowserTest.PendingContributionTip (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2027)
02:59:58 BraveRewardsBrowserTest.RecurringTipForUnverifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:1809)
02:59:58 BraveRewardsBrowserTest.RecurringTipForVerifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:1788)
02:59:58 BraveRewardsBrowserTest.TipConnectedPublisherAnon (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2408)
02:59:58 BraveRewardsBrowserTest.TipConnectedPublisherAnonAndConnected (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2428)
02:59:58 BraveRewardsBrowserTest.TipUnverifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:1768)
02:59:58 BraveRewardsBrowserTest.TipVerifiedPublisher (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:1749)
02:59:58 3 tests timed out:
02:59:58 BraveRewardsBrowserTest.MultipleRecurringOverBudgetAndPartialAutoContribution (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2559)
02:59:58 BraveRewardsBrowserTest.ProcessPendingContributions (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2251)
02:59:58 BraveRewardsBrowserTest.RecurringAndPartialAutoContribution (../../brave/components/brave_rewards/browser/rewards_service_browsertest.cc:2512)
@petemill should I still see extension in Task manager? I just build the PR on clean profile and opened task manager |
Unable to reproduce test failures locally, @petemill are you? |
@ryanml one thing could be that locally you are building as debug where CI is doing release which is a lot faster and you probably don't see this race condition on slower build |
c8b0db9
to
c8df68b
Compare
Fixed some of the panel issues via c8df68b Still some test issues, especially wrt the grant-finished UI showing when the grant is solved elsewhere. Pinged @ryanml and @NejcZdovc about it. |
…ound script This is now controlled by native 'stub' button
… after some time of unloadedness
The default extension browser action image was set to 16dp when brave browser actions currently uses 18dp. This was barely noticeable when the extensions were loaded on profile creation since only the first window would make this jump and it would happen when the window is opening whilst other paints are occurring. Now that the rewards extension is delay-loaded when the button is clicked, it is more noticeable.
Adds call to braveRewards.getGrants() if rewards is already enabled at extension startup. Puts get* calls after on* calls so that there is no possibility for items to be missed
ClaimGrant function was clicking on the Finish button. Occasionally this would work because the UI was still there, but since the 'finish' happens from C++, the UI proceeds on its own
c8df68b
to
221129c
Compare
No, that's weird @NejcZdovc . Very weird. I cannot replicate. could you try again? |
So I fixed the only remaining browser test by removing the forced button click to move from captcha to 'celebration' screen (or whatever you call that!). Not sure why clicking that button worked in master and not on this branch. |
Looks like all tests passed on this one now
Just got the normal lint failure. |
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.
rewards side looks good
Replaces the rewards toolbar icon with a non-extension-related Button. When the button is clicked, the Rewards extension will be loaded. The extension browser action button will replace the previous 'stub' button and the popup will automatically open.
If the profile starts with rewards already enabled then the extension is immediately started.
Fix brave/brave-browser#3436
Related but (probably) not blocking:
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
1. Panel works on fresh data directory
Can also verify extension loaded status in Brave Task Manager
2. Existing rewards profile
Additional profiles in same data directory
Verify 1. and 2. but with new profiles in the same browser session. (App Menu -> Create New Profile). Each profile should have or not have its own copy of the brave rewards extension, and behave as per test 1. and 2.
cli flag to disable
--disable-brave-rewards-extension
Reviewer Checklist:
After-merge Checklist:
changes has landed on.