Stylus: Stylus Unable to Communicate With Gmail Pages

Created on 5 May 2019  Â·  20Comments  Â·  Source: openstyles/stylus

  • Chrome 73
  • Windows 7
  • Stylus 1.5.3

stylus-broken

This just started today, it was working fine before that. On any tabs with Gmail I get the following error:

Could not communicate with the page. Try reloading the tab.
Stylus can access file:// URLs only if you enable the corresponding checkbox for Stylus extension on chrome://extensions page.

Of course I'm not using a file:// URL, so I'm not sure why that shows up. I have tried restarting Chrome, disabling/re-enabling Stylus and uninstalling and reinstalling Stylus. None of that helped. Stylus is working fine in a tab for Google Voice, so I don't think it's a Google thing.

I've tried enabling it to access file:// URLs just in case, with no luck. (The error message does not change when doing that, it still says it can't access file:// URLs.) Also turned on collect errors and am not getting any. I've even disabled _all_ my other extensions, but nothing changed, still the same error.

Oddly, this isn't happening on other profiles in the same Chrome install, but I've run out of ideas on how to fix it myself.

external

Most helpful comment

Do you still have this issue? I've seen a Chrome bug which may relate to Chrome Apps. Try:

  1. Go to chrome://apps/.
  2. Find Gmail.
  3. Right-click -> Remove from Chrome.

This might be the same problem as #659.

I just now saw this, and holy crap, it fixed it _immediately_. I don't have time to check all my profiles, but I checked a couple right quick and the ones that were working didn't have the Gmail app installed. Looks like that was my entire problem. I don't think it's always installed by default, though, at least not all the time, because I have profiles that were created around the same time (using the same version of Chrome) both with and without it. I've never added it manually, because I don't use it.

Thanks so much, it's nice to have my icons+text back in the composer!

All 20 comments

Oddly, this isn't happening on other profiles in the same Chrome install

Good indication there's something wrong with that profile. I see no communication issues with gmail in Chromium either.

ideas on how to fix it myself

You could try exporting your DB, uninstalling, reinstalling, then importing your DB. If that doesn't work, you might be SOL, sometimes profiles get borked.

For what it's worth, it's started collecting errors, they're all the same thing:

// In Chrome content script is orphaned on an extension update/reload
// so we need to detach event listeners
[docRewriteObserver, docRootObserver].forEach(ob => ob && ob.disconnect());
window.removeEventListener(chrome.runtime.id, orphanCheck, true);
try {
msg.off(applyOnMessage);
} catch (e) {}

The _window.removeEventListener(chrome.runtime.id, orphanCheck, true);_ line is highlighted in yellow.

I'm not sure what database you're referring to, I did try that with the extension (exported all my styles, uninstalled, re-installed, imported styles), and I can't really do it with Chrome, since it's a portable install. Plus I have 12 profiles, wiping all that and starting over is... excessive. I'd probably give up on Chrome at that point.

If Chrome profiles randomly bork themselves when they're barely being used (basically Gmail and Voice) then there's something _seriously_ wrong with Chrome. I have had profiles break in Firefox, but not that easily. That's way too fragile.

I think Chrome must be blocking it. Another extension User CSS also stopped working.

So... I fired up Edge DEV (Chromium based Edge) and installed Stylus and it works as expected.

Open chrome://policy and see if there are any runtime_blocked_hosts - sometimes corporate network admins forbid extensions on business-related sites, gmail is a common victim.

BTW this might be something worth adding to Stylus wiki.

Nope not on a corporate network any anything similar, my home PC. But checked policies any way as suggested, nothing.

Maybe you've switched site permissions in chrome://extensions page for Stylus.

sigh... no I did not. As mentioned, Stylus is not the only one that stopped working on the Gmail page, only. The User CSS extension also stopped working. They both work on other pages. AND, they both extensions work when using the new Edge (Chromium based browser).

Could be caused by a pre-installed extension for offline something (like Drive or Documents maybe) that comes with Chrome.

I just had this same thing happen to me -- only Stylus is affected, and only on Gmail. I haven't updated Chrome recently, installed/uninstalled any other extensions, or changed the permissions for Stylus. Chrome isn't managed by an enterprise policy.

This seems like fallout from some A/B test Gmail is running on a small group of users.

EDIT: strike that, other extensions that rely on injecting content into the page aren't working with Gmail either.

Update: I cloned the repo and did some experimenting, and was able to boil my symptoms down to this:

// error
msg.sendTab(gmailTabId, {method: 'ping'}, {frameId: 0})
      .catch(console.error)
      .then(console.log)

// works
msg.sendTab(gmailTabId, {method: 'ping'}, {})
      .catch(console.error)
      .then(console.log)

By removing frameId: 0 from popup.js, I was able to make the error message in the popup go away. I wasn't able to get injected styles to work, but that may just be because there's a lot of moving parts and I was doing something wrong. Obviously referencing only the top frame is sometimes important, so I'm not exactly surprised that half-blindly pulling out chunks of code didn't yield perfect results.

When I mentioned in my previous comment that I hadn't updated or restarted Chrome recently, what that really meant was that I hadn't restarted Chrome in about a month. I keep a lot of windows open spread out across a lot of monitors, and restarting my browser is a pain that I like to avoid. I basically only do it to update Chrome. As I was poking around at tab messaging, I noticed that the tab IDs I was seeing were much larger than I'm used to seeing - my Gmail tab was 999507528. That's not too close to any magic numbers I'm aware of, but it's still pretty big, and starting with three 9's seemed kind of interesting. So since nothing else was making much sense, I decided to try restarting my browser (WITHOUT installing any updates, to keep everything else as similar as possible). Once I did that, all my extensions that inject code into Gmail (Stylus, Tampermonkey, etc) started working normally.

I still have no idea why this weird issue only seemed to affect Gmail tabs. I tested numerous other sites, both Google and non-Google, in new tabs that would have also had similarly high IDs, and Stylus was able to interact all of them. And this problem first manifested itself when I refreshed an existing Gmail tab, so its ID wouldn't have changed then. I'd also tried creating a brand new Chrome profile with just Stylus installed, and the results were exactly the same there. I've previously kept Chrome open for multiple months at a time, and I've never seen this issue before.

So uhh... ¯\_(ツ)_/¯

I hadn't restarted Chrome in about a month... I decided to try restarting my browser... Once I did that, all my extensions that inject code into Gmail (Stylus, Tampermonkey, etc) started working normally.

Mystery solved, if you ask me. You seem vaguely aware that not restarting Chrome in a month is not typical. Even if, theoretically, you should be able to run it non-stop, and never clear the history/cache, I've never found either of those things to be true.

I've run into countless inexplicable heisenbugs which were simply solved by clearing everything and restarting, which is the browser equivalent of "Have you tried unplugging it, and plugging it back in?". When that fixes the problem, that's a good indication the browser hit a glitch and got stuck on stupid.

You seem vaguely aware that not restarting Chrome in a month is not typical.

...yeah...

If it hadn't been inexplicably limited to Gmail, I'd have just assumed this was related to one of the many atypical ways I use a browser and done a lot more troubleshooting on my end, but when I saw someone else had seemingly had the same exact symptoms, that looked like a pattern.

It looks like that wasn't the case. But since I'd already gone and opened my mouth here, I figured I'd at least give an explanation for what happened to make me so sure that a two month old issue had just started affecting me today.

Anyway, I'm just glad I managed to get it sorted on my own before anyone else wasted any time trying to troubleshoot it.

Do you still have this issue? I've seen a Chrome bug which may relate to Chrome Apps. Try:

  1. Go to chrome://apps/.
  2. Find Gmail.
  3. Right-click -> Remove from Chrome.

This might be the same problem as https://github.com/openstyles/stylus/issues/659.

Definitely similarities. Weird that it's even included by default. Another solution would be to switch to a Chromium fork which Google hasn't completely ruined.

I noticed this problem for me on all google pages of the google domain *.google.com (Gmail, drive, youtube, docs etc...)

It seems that no CSS can be modified by any extension Stylus included. I tried several other CSS injecting ones (like Styler Classic) with no success.
I thought it might be related to Chrome preventing AdBlocker-like apps https://9to5google.com/2019/05/29/chrome-ad-blocking-enterprise-manifest-v3/

I tried removing all the apps in chrome://apps/ and in incognito mode with no other extensions installed but the problem persisted.

I'm on Mac OS 10.14.6 using Stylus 1.5.4.
Google Chrome Version 75.0.3770.142 (Official Build) (64-bit)

EDIT: Added Chrome version

Please clarify which version of Chromium.

Added the Chrome version to my previous message too

Google Chrome
Version 75.0.3770.142 (Official Build) (64-bit)

Well, that rules out manifest v3, since it's scheduled to land in Canary right around now. Not sure if it has yet or not, but it wouldn't be a factor in v75. Anyway, changes to the webRequest API shouldn't cause the type of behavior you're describing.

This is one of the weirder issues here, because what you're describing should not be possible under normal circumstances, the reports are few and far between, nobody can repro, and nobody's checked back in with any useful conclusions. The possible conflicts have been speculated already, mainly:

  1. Open chrome://policy and see if there are any runtime_blocked_hosts - sometimes corporate network admins forbid extensions on business-related sites, gmail is a common victim.

  2. Extension conflicts

  3. chrome://apps/ conflicts

Beyond that, I guess if you've flipped any chrome://flags you might try setting them all back to defaults. Test other Chromium forks and see if there's any issues. If you figure anything out, post an update.

Crap! You're damn right. Just found the culprit: Those sites are under runtime_blocked_hosts. I guess there's no workaround :(

Do you still have this issue? I've seen a Chrome bug which may relate to Chrome Apps. Try:

  1. Go to chrome://apps/.
  2. Find Gmail.
  3. Right-click -> Remove from Chrome.

This might be the same problem as #659.

I just now saw this, and holy crap, it fixed it _immediately_. I don't have time to check all my profiles, but I checked a couple right quick and the ones that were working didn't have the Gmail app installed. Looks like that was my entire problem. I don't think it's always installed by default, though, at least not all the time, because I have profiles that were created around the same time (using the same version of Chrome) both with and without it. I've never added it manually, because I don't use it.

Thanks so much, it's nice to have my icons+text back in the composer!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

narcolepticinsomniac picture narcolepticinsomniac  Â·  74Comments

eight04 picture eight04  Â·  30Comments

vsemozhetbyt picture vsemozhetbyt  Â·  39Comments

xt0rted picture xt0rted  Â·  51Comments

Aqa-Ib picture Aqa-Ib  Â·  85Comments