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

[Desktop] race condition with Greaselion and localizations #12264

Closed
LaurenWags opened this issue Oct 21, 2020 · 12 comments · Fixed by brave/brave-core#7141
Closed

[Desktop] race condition with Greaselion and localizations #12264

LaurenWags opened this issue Oct 21, 2020 · 12 comments · Fixed by brave/brave-core#7141

Comments

@LaurenWags
Copy link
Member

LaurenWags commented Oct 21, 2020

Description

I noticed that the "Tip" text wasn't displaying next to the in-line BAT logo on twitter. When this happens, if you click on the in-line tip icon, sometimes (not always) nothing will happen (no tip banner opens).

Per discussion with @emerick there is a race condition with localizations that causes the text to not display properly. A browser restart fixes this.

Steps to Reproduce

Unsure if the below will work 100% of the time:

  1. Clean profile
  2. Enable Rewards
  3. Navigate to a twitter page like twitter.com/brave
  4. Look at the tweets on the page.
  5. Click on icon.

Actual result:

No "Tip" text next to the BAT logo and when you click on it, the banner may or may not open.
1 17 x

Expected result:

should say "Tip" and "Tip" should change to orange when hovered over. Should be able to click on the BAT logo/text and the tip banner should be displayed.
Screen Shot 2020-10-21 at 2 16 46 PM
1 15 x

Reproduces how often:

intermittent, race condition

Brave version (brave://version info)

Brave 1.17.45 Chromium: 86.0.4240.99 (Official Build) dev (x86_64)
Revision 002668237e13d38aabd6d11c2d216dd22b736ff2-refs/branch-heads/4240@{#1229}
OS macOS Version 10.14.6 (Build 18G3020)

Version/Channel Information:

  • Can you reproduce this issue with the current release? n/a
  • Can you reproduce this issue with the beta channel? yes
  • Can you reproduce this issue with the nightly channel? yes

Other Additional Information:

  • Does the issue resolve itself when disabling Brave Shields?
  • Does the issue resolve itself when disabling Brave Rewards?
  • Is the issue reproducible on the latest version of Chrome?

Miscellaneous Information:

cc @emerick @NejcZdovc

@emerick
Copy link
Contributor

emerick commented Oct 21, 2020

We think this is caused by or related to this upstream bug: https://bugs.chromium.org/p/chromium/issues/detail?id=83549.

@GeetaSarvadnya
Copy link

Reproduced in Windows 10 x64 - 1.18.2

image

@bsclifton bsclifton changed the title [Desktop] race condition with greaselion and localizations [Desktop] race condition with Greaselion and localizations Oct 26, 2020
@LaurenWags
Copy link
Member Author

LaurenWags commented Oct 28, 2020

Reproduces on Reddit as well:
Screen Shot 2020-10-28 at 9 44 07 AM

Brave 1.17.53 Chromium: 86.0.4240.111 (Official Build) dev (x86_64)
Revision b8c36128a06ebad76af51591bfec980224db5522-refs/branch-heads/4240@{#1290}
OS macOS Version 10.14.6 (Build 18G6032)

@btlechowski
Copy link

Reproduced on

Brave 1.17.59 Chromium: 86.0.4240.183 (Official Build) dev (64-bit)
Revision 0b568b034b8f7994697cb341eeca5979b84151cc-refs/branch-heads/4240@{#1374}
OS Ubuntu 18.04 LTS

image

Steps:

  1. With rewards enabled, open https://old.reddit.com/user/alex_the_brave in a new tab

Note: Browser restart fixes the issue
Note: Page reload does not fix the issue

@LaurenWags
Copy link
Member Author

This happens almost every time I open a GH page:
Screen Shot 2020-11-04 at 2 55 14 PM

Close/reopen of the browser fixes it:
Screen Shot 2020-11-04 at 2 56 05 PM

Brave | 1.17.60 Chromium: 86.0.4240.185 (Official Build) dev (x86_64)
-- | --
Revision | 37e6f852ed18086458552039ad26421aa9fc7acc-refs/branch-heads/4240@{#1377}
OS | macOS Version 10.14.6 (Build 18G6032)

@LaurenWags
Copy link
Member Author

Removed intermittent-issue as this happens about 80-90% of the time for me. It's incredibly prevalent.

@emerick
Copy link
Contributor

emerick commented Nov 12, 2020

When this fails for me, it's due to the contents of the following directory being deleted: C:\Users\emerick\AppData\Local\BraveSoftware\Brave-Browser\User Data\Default\Extensions.

It seems like there are two problems here:

  1. Brave never explicitly deletes its Greaselion extension directories on shutdown, so those directories continue to proliferate in the temp directory. @jonathansampson also noticed this on his computer.
  2. Something periodically comes along and completely wipes out the extensions temp directory (see above). I'm not sure if that's just some housekeeping that Chromium does, but when that occurs our localizations stop working (I guess they're not read into memory?)

@emerick emerick self-assigned this Nov 12, 2020
@jonathansampson
Copy link
Contributor

jonathansampson commented Nov 13, 2020

I often see Failed to fetch user details for : Missing auth headers as well. You can trigger this message by switching away from Twitter, and back. It's fairly easy to reproduce in my experience. This makes sense, since I am apparently also never able to actually trigger the handleOnSendHeadersWebRequest method either:

const handleOnSendHeadersWebRequest = (mediaType: string, details: any) => {
  if (mediaType !== types.mediaType || !details || !details.requestHeaders) {
    return
  }
  if (auth.processRequestHeaders(details.requestHeaders)) {
    tipping.configure()
  }
}

That handler is registered successfully, but never called:

webRequestHandlers.registerOnSendHeadersWebRequest(
  types.mediaType,
  types.sendHeadersUrls,
  types.sendHeadersExtra,
  handleOnSendHeadersWebRequest)
tabHandlers.registerOnUpdatedTab(types.mediaType, handleOnUpdatedTab)

@emerick
Copy link
Contributor

emerick commented Nov 13, 2020

@jonathansampson I've got a fix for the localizations bug teed up, I just need to clean it up and PR it (most likely in the morning at this point).

I have seen that Twitter error message, but I think it's probably unrelated to this. As long as tipping and the panel works correctly, it should be doing the right thing. It will often write out that message due to the timing of when we receive the auth cookie, but it's typically a benign message. It's weird if you're not seeing it triggered, though. Most of the publisher sites are split into two separate scripts (and soon three), so it could possibly be that only one is receiving that?

@jonathansampson
Copy link
Contributor

@emerick Tipping isn't working when I see this error; clicking the inline tipping button raises the following:

Failed to fetch tweet metadata for [object HTMLElement]: Error: Missing auth headers
    at api.ts:19
    at new Promise (<anonymous>)
    at sendAPIRequest (api.ts:11)
    at Module.getTweetDetails (api.ts:82)
    at getMediaMetaData (tipping.ts:22)
    at HTMLButtonElement.tipButton.onclick (tipping.ts:140)

@emerick
Copy link
Contributor

emerick commented Nov 13, 2020

@jonathansampson OK, gotcha - then it's definitely not what I was thinking. Do you mind creating a new issue with that info and the steps to repro that you mentioned earlier and we'll prioritize it? Thank you!

@LaurenWags
Copy link
Member Author

LaurenWags commented Nov 18, 2020

Verified passed with

Brave | 1.17.70 Chromium: 87.0.4280.60 (Official Build) (x86_64)
-- | --
Revision | 12697cfeb273d7de95cf9b18350d2c457f58224c-refs/branch-heads/4280@{#1352}
OS | macOS Version 10.14.6 (Build 18G6042)

Verified test plan from brave/brave-core#7141 (comment)

Opened multiple tabs w/ in-line tip buttons. Examples:

Generally confirmed:

  • Navigating thru the various pages/page types above and confirming "Tip" text and button were displayed.
  • Opening new pages via context menu and confirming when opening the page it loaded and the "Tip" text and button were displayed.
  • Closing tabs and reopening using cmd+shift+T. When tab is reopened and loaded the "Tip" text and button were displayed.
  • Leaving various pages as active and then close/reopen the browser. On relaunch pages generally showed the "Tip" text and button, except for Twitter pages. This is logged with Greaselion script doesn't run when browser is launched with open tabs #11825. Reload fixes it. Also confirmed reloading a tab that was left over from previous session showed the "Tip" text and button once page loaded.

Verification passed on

Brave 1.17.70 Chromium: 87.0.4280.60 (Official Build) (64-bit)
Revision 12697cfeb273d7de95cf9b18350d2c457f58224c-refs/branch-heads/4280@{#1352}
OS Windows 7 Service Pack 1 (Build 7601.24544)

Verified test plan from brave/brave-core#7141 (comment)

Opened multiple tabs w/ in-line tip buttons. Examples:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment