brave-browser: Canvas context method getImageData is producing some inconsistent color values in a blank canvas.
Description
Canvas context method getImageData is producing some inconsistent data values in a blank canvas. It’s always the green color value and it is sometimes set to 1. It should always be 0.
Steps to Reproduce
Here is a script to log the results:
<canvas id="mycanvas" width="2" height="5"></canvas>
<script>
var canvas = document.getElementById( "mycanvas" );
var context = canvas.getContext( "2d" );
var data = context.getImageData( 0, 0, 2, 5 ).data;
for( var i = 0; i < data.length; i += 4 ) {
var r = data[ i ];
var g = data[ i + 1 ];
var b = data[ i + 2 ];
var a = data[ i + 3 ];
console.log( r, g, b, a );
}
</script>
Actual result:
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
Expected result:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Reproduces how often:
Every time.
Brave version (brave://version info)
Version 1.8.86 Chromium: 81.0.4044.129 (Official Build) (64-bit)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 22 (11 by maintainers)
I don’t mean to revive this Issue, but based on the blog post that finally mentions this ( I had originally posted the same problem at https://community.brave.com/t/canvas-todataurl-image-png-introduces-noise/120854/5 long before that post ) and the above replies, I’m led to believe that there should be a setting which would disable the introduction of these protective measures.
Could you detail exactly which setting of combination of settings that would be? Neither ‘Shields down’ nor specifically setting ‘allow all fingerprinting attempts’ seemed to do the trick.
I’m in a similar situation as OP; I generate images that require exact colors. When I turn the canvas to an image (via .toDataURL) for storage, and that resulting image is then loaded back into my site (technically there’s also an internal part that passes the data around that way, but that could be avoided), my site complains that there’s a bunch of pixels that don’t match.
So, just like OP, I’ve had to essentially add a Brave Compatibility mode, detecting Brave through:
(navigator.brave && navigator.brave.isBrave())
and allowing a lowest bit difference in any of the RGB channels, while also presented this as a UI option in case there’s any future forks of Brave or other browsers implementing this measure that would have the same issue. This does slow down some features of the site a little, and ultimately still causes any Brave Browser user to generate images that have this noise which may confound users of other browsers, but I understand that may be a price that some are willing to pay for privacy.But my site (though not my test page anymore, will have to figure out why) does detect the farbling of the canvas, and does work around it… just not for any privacy-affecting purposes.
I have to admit I’m curious as to what type of fingerprinting this introduction of noise is intended to thwart, but this Issue may not be the place to do so.
@Undoundoundo yep, once the work described https://brave.com/whats-brave-done-for-my-privacy-lately-episode-4-fingerprinting-defenses-2-0/ is finished (anticipating, but not promising, 2-3 weeks) the fingerprinting shields control will switch from controlling the current “disable the feature” fingerprinting system, and will control the new farbling defenses.
So, exactly what you’re asking for will be in place shortly 😃