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

Brave breaks emoji support detection #14

Open
eteeselink opened this issue Oct 23, 2021 · 0 comments
Open

Brave breaks emoji support detection #14

eteeselink opened this issue Oct 23, 2021 · 0 comments

Comments

@eteeselink
Copy link

eteeselink commented Oct 23, 2021

Hi there,

First, thanks for making this, it's been a godsend.

Brave apparently has "anti fingerprinting" code in their getImageData() method, which makes is-emoji-supported return incorrect results.

To repro, compare this codesandbox in Chrome vs Brave: https://codesandbox.io/s/serene-joliot-hjbef

It's obviously an issue with Brave and not your code, but it still means that code that uses this library is effectively broken for Brave users. I'd be happy to provide a PR that addresses it, but I figured it might be worth discussing approaches first.

1. Simply don't support Brave

A valid choice, given that it's Brave who's not respecting the spec. That said, browsers not respecting specs is common, and a library that exists to test browser support for something might be expected to be able to deal with that.

2. Allow slight color differences

Brave returns colors from getImageData that are very close to the actual colors. Eg when testing, I found that it returned an (0,0,0,16) rgba pixel value as eg (1,0,1,16). We could edit the code to allow small color variations, eg let each channel (r, g, b, a) vary by 1 or 2 points.

3. Allow slight color differences on Brave only

Wrap the loose approach from point 2 in a if(navigator.brave.isBrave)

4. Compare more than one pixel

Brave does not obfuscate every byte, which is why the codesandbox link shows some emojis as supported and some as not. Given that we're checking that the font color is fully ignored when emojis are rendered, it might be good enough when some pixels are equal. Eg compare up to 10 pixels and only fail when none of them match.

I think that personally I lean towards option 3 which is very explicitly Brave-only. This makes maintenance easy because it's a clear hack for a specific browser's specific bug. I'll be happy to provide a PR.

Curious about your thoughts!

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

No branches or pull requests

1 participant