brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.58k stars 2.28k forks source link

bitFlyer promo card re-appearing in certain cases even though dismissed #21568

Open kjozwiak opened 2 years ago

kjozwiak commented 2 years ago

Description

Seems intermittent but there's cases where the bitFlyer promo code re-appears even though the user has tapped/clicked on X or Don't show me again.

Steps to reproduce

Prerequisite: ensure that the device locale is set as Japan

  1. install 1.38.32 Chromium: 99.0.4844.51
  2. launch the browser and enable rewards
  3. go into brave://rewards and notice the promo card being available/visible
  4. close the banner via X or Don't show again and close the browser right after
  5. re-launch the browser and notice that the promo card is still visible

Actual result

Example of the issue occurring --> https://youtu.be/FDkg1yCUgC8

Expected result

When the user taps/presses on either X or the Don't show again buttons/text, it shouldn't re-display the banner in any case.

Issue reproduces how often

Seems intermittent but I managed to reproduce it 100% using the STR/Cases.

Version/Channel Information:

Device details

Brave version

1.38.32 Chromium: 99.0.4844.51

Website problems only

Additional information

CCing @Uni-verse @srirambv @emerick @Miyayes

emerick commented 2 years ago

I feel like since we do a "debounced" save with a timeout, it's possible to close the promo card and quickly exit the browser before that state change is persisted in localStorage. It feels like this is a fundamental flaw with this approach, but perhaps we can perform a save when the component unmounts (assuming that doesn't already happen and that it would get called on Android when "swiping up" to close the browser). Would you have any advice here @zenparsing?

zenparsing commented 2 years ago

@emerick If the debouncing is the source of the problem, then a simple fix might be to override the debouncing for certain action types. For example, in the mergeReducers function, you might be able to do something along the lines of:

  if (state !== startingState) {
    if (action.type === types.DISMISS_PROMO_PROMPT) {
      storage.save(state)
    } else {
      storage.debouncedSave(state)
    }
  }

I'm not quite sure whether the "componentWillUnmount" approach will work or not - does it get called from window.onunload and does it get called when the app is closed, and is it easy to grab the state from outside of the Redux flow?

kjozwiak commented 2 years ago

Removing the release/blocking label. We should be fine if this isn't fixed in 1.37.x. To reproduce the above issue, the user basically needs to restart Brave right after closing the promo card. I don't think most users will be running into the above issue.