Skip to content

Commit

Permalink
Fix brave/brave-ios#8109: Don't call fetch promotions on uninitialize…
Browse files Browse the repository at this point in the history
…d rewards services (brave/brave-ios#8110)

Calling rewards engine APIs before the engine has been initialized can cause a crash because the `WhenReady` method used inside `RewardsEngineImpl` will queue up what is assumed a `SingleThreadedTaskRunner`. This is not the case for iOS which uses a standard sequenced task runner.

This call to fetch promotions happens when showing the rewards panel but the rewards engine may not be initialized until the panel is shown (a sec/privacy requirement to not make API calls to rewards services until a user interacts with the feature), so it was being scheduled instead of executing immediately, thus hitting the threading issue on the brave-core side
  • Loading branch information
kylehickinson committed Sep 20, 2023
1 parent 1ad3d78 commit 7a7754b
Showing 1 changed file with 0 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ extension BrowserViewController {
}
// Hide the current tab
rewards.rewardsAPI?.selectedTabId = 0
// Fetch new promotions
rewards.rewardsAPI?.fetchPromotions(nil)
}

func claimPendingPromotions() {
Expand Down

0 comments on commit 7a7754b

Please sign in to comment.