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

[Bug]: Gradient on text fill doesnt work on chrome 111 and above #8829

Open
7 tasks done
ebigtm opened this issue Apr 8, 2023 · 15 comments
Open
7 tasks done

[Bug]: Gradient on text fill doesnt work on chrome 111 and above #8829

ebigtm opened this issue Apr 8, 2023 · 15 comments

Comments

@ebigtm
Copy link

ebigtm commented Apr 8, 2023

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have read and followed the Issue Tracker Guide
  • I have searched and referenced existing issues and discussions
  • I am filing a BUG report.
  • I have managed to reproduce the bug after upgrading to the latest version
  • I have created an accurate and minimal reproduction

Version

5.3.0

In What environments are you experiencing the problem?

Chrome

Node Version (if applicable)

None

Link To Reproduction

https://jsfiddle.net/EYBTM/ohqsj72b/14/

Steps To Reproduce

As you will see in the fiddle when openning on an updated chrome (checked on both mac and windows but not linux)
the text which should be on the black box is lacking, if opened on an older version of chrome or any other browser (even updated edge) the text appears

What i found is that if i disable GPU rasterization under
chrome://flags/#enable-gpu-rasterization

the issue will not happen

I was testing regular canvas on text and it appears fine:
https://jsfiddle.net/EYBTM/s957ge3y/1/

Expected Behavior

The text should appear with gradient

Actual Behavior

text is transparent

Error Message & Stack Trace

No response

@ebigtm
Copy link
Author

ebigtm commented Apr 8, 2023

btw it happens on any older version of fabric as well

@iocoker
Copy link
Contributor

iocoker commented Apr 8, 2023

@ebigtm Can you check this if it works for you?: #8168 (comment)

@ebigtm
Copy link
Author

ebigtm commented Apr 9, 2023

@iocoker works like a charm! exactly what I was looking for thanks!!!

@ebigtm
Copy link
Author

ebigtm commented Apr 9, 2023

@iocoker ok now i see theres a problem with the angles
here are how it should be and how it looks, I will try to fix it and updated you
https://drive.google.com/open?id=1tro8wDorEBlwpOcflQLhoWvmyGGCFfJZ&authuser=elad%40flowmo.design&usp=drive_fs

@iocoker
Copy link
Contributor

iocoker commented Apr 9, 2023

@ebigtm You're right, the angle is off. @ShaMan123 any pointers please ?

Also forgot to add a Radial to the hack:
`

			let coords = {
				x1: this.width * filler.coords.x1,
				y1: this.height * filler.coords.y1,
				x2: this.width * filler.coords.x2,
				y2: this.height * filler.coords.y2,
				r1: Math.abs(filler.coords.r1 || 0) * Math.max(this.width, this.height),
				r2: Math.abs(filler.coords.r2 || 0) * Math.max(this.width, this.height),
			};

			let gradient = filler.type === 'linear'
							? ctx.createLinearGradient(coords.x1, coords.y1, coords.x2, coords.y2)
							: ctx.createRadialGradient(coords.x1, coords.y1, coords.r1, coords.x2, coords.y2, coords.r2);

`

@ShaMan123
Copy link
Contributor

We have a failing visual test that might be related.
I can link it when I am in front of my machine.
I refactored fillers in a PR and tried to change how fabric render gradients to cache using transfomations... because now is is weird and wasteful.
We need to revisit that.
You are welcome to look.
I will add the pr ref here.
I don't remember what this is all about because a long time has passed.
It is important to reproduce without fabric to eliminate it is not a browser bug.

@ShaMan123
Copy link
Contributor

#8263

@ShaMan123
Copy link
Contributor

I read you triaged it to be a chrome bug. Is that correct?

@ShaMan123
Copy link
Contributor

https://github.com/fabricjs/fabric.js/blob/master/test/visual/text.js#L212

I think that is the test
Run in with:
npm test -- -d -c chrome

@ebigtm
Copy link
Author

ebigtm commented Apr 10, 2023

@ShaMan123 yes only chrome bug and only on version 111 and 112 of chrome (edge works fine!)

thanks! Will look into it

@ShaMan123
Copy link
Contributor

Happy to see you back

@ShaMan123
Copy link
Contributor

If both you guys want to help me with 2 clicks then enter the following link and add a thumbs up reaction to the description

microsoft/vscode#173782 (comment)

@iocoker
Copy link
Contributor

iocoker commented Apr 10, 2023

Thanks, done. I'll get a few colleagues to upvote for you tomorrow when I get to the office.

@iocoker
Copy link
Contributor

iocoker commented Apr 10, 2023

Yeah, the test ran fine
text7

@Tomasgb97
Copy link

I have a similar issue happening when i use an image to mask a text and use it as a background, works just fine on firefox, but not on chrome, has someone found the same problem or simillar ? the gradient pattern solution doesnt seem to work in this case.

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

No branches or pull requests

4 participants