Closed Bug 752341 Opened 12 years ago Closed 12 years ago

canvas fillText stopped supporting gradient fill

Categories

(Core :: Graphics, defect)

12 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15
Tracking Status
firefox13 + verified
firefox14 + verified
firefox15 + verified

People

(Reporter: gmc, Assigned: jrmuizel)

References

Details

(Keywords: regression, Whiteboard: [qa+])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0
Build ID: 20120420145725

Steps to reproduce:

Loaded the following HTML:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>bug demo</title>
</head>
<body>
<canvas id="mycanvas" width="300" height="300"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('mycanvas');
var ctx = canvas.getContext('2d');
ctx.font = "bold 36px sans-serif";
var gradient = ctx.createLinearGradient(0, 0, 150, 100);
gradient.addColorStop(0, "rgb(255, 0, 0)");
gradient.addColorStop(1, "rgb(255, 255, 0)");
ctx.fillStyle = gradient;
ctx.fillText("Hello, world..", 10, 100);
</script>
</body>
</html>


Actual results:

Nothing was shown.


Expected results:

The text "Hello, world.." should have been shown with a gradient fill going from red in the top left to yellow in the bottom right.
Component: Untriaged → Canvas: 2D
Product: Firefox → Core
QA Contact: untriaged → canvas.2d
Regression range:

http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=34572943a3e4&tochange=f4049f65efc6

Turning off Azure canvas on Mac makes the bug go away, so this is a bug in either azure canvas or the coregraphics azure backend.
Blocks: 692879
Status: UNCONFIRMED → NEW
Component: Canvas: 2D → Graphics
Ever confirmed: true
QA Contact: canvas.2d → thebes
Sending over to JP to find an assignee on the gfx team. If for whatever reason this goes unfixed in FF13, we don't expect major fallout given the lack of dupes here.
Assignee: nobody → jpr
Keywords: regression
Assignee: jpr → jmuizelaar
If this helps, we use different gradient and different fill code in TenFourFox's 10.4 version of CG Azure. On my internal build of 12, I get Hello, w and part of the o.

        for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
                CGContextSaveGState(cg); // push the "non-clip" on the stack
                CGContextSetTextDrawingMode(cg, kCGTextClip);
                it[0] = aBuffer.mGlyphs[i].mIndex;
                CGContextShowGlyphsAtPoint(cg, 
                        aBuffer.mGlyphs[i].mPosition.x,
                        aBuffer.mGlyphs[i].mPosition.y,
                        it, 1);
                DrawGradient(cg, aPattern);
                CGContextRestoreGState(cg); // pop the clip off
        }
It looks like we're hitting the problem mentioned in this commit:

http://cgit.freedesktop.org/cairo/commit/?id=9c0d761bfcdd28d52c83d74f46dd3c709ae0fa69

I'm not sure how best to fix it yet.
Attachment #625109 - Flags: review?(matt.woodrow)
Attachment #625109 - Flags: review?(matt.woodrow) → review?(bgirard)
Attachment #625109 - Flags: review?(bgirard) → review+
(In reply to Jeff Muizelaar [:jrmuizel] from comment #6)
> https://hg.mozilla.org/integration/mozilla-inbound/rev/05f23d27c37a

If this patch is low risk, please nominate for aurora/beta approval prior to tomorrow's beta 5 go to build.
Comment on attachment 625109 [details] [diff] [review]
Avoid using CGContextSetTextMatrix

[Approval Request Comment]
Bug caused by (feature/regressing bug #): 692879
User impact if declined: Gradient fills for text won't work on OS X
Testing completed (on m-c, etc.): limited (I haven't had a chance to test this much) It does pass the our reftests and mochitests so it's unlikely to break anything too badly.
Risk to taking this patch (and alternatives if risky): Canvas text could paint in the wrong place or not at all.
String or UUID changes made by this patch: None
Attachment #625109 - Flags: approval-mozilla-beta?
Attachment #625109 - Flags: approval-mozilla-aurora?
(In reply to Jeff Muizelaar [:jrmuizel] from comment #8)
> Risk to taking this patch (and alternatives if risky): Canvas text could
> paint in the wrong place or not at all.

Would you consider this as having a very low probability of regression? If not, we'd probably have this only land in FF14 and up given where we are in the cycle.
(In reply to Alex Keybl [:akeybl] from comment #9)
> (In reply to Jeff Muizelaar [:jrmuizel] from comment #8)
> > Risk to taking this patch (and alternatives if risky): Canvas text could
> > paint in the wrong place or not at all.
> 
> Would you consider this as having a very low probability of regression? If
> not, we'd probably have this only land in FF14 and up given where we are in
> the cycle.

I can do some testing tomorrow that should give an idea if this is likely to cause a regression. I should have a pretty good feeling after that.
(In reply to Jeff Muizelaar [:jrmuizel] from comment #10)
> (In reply to Alex Keybl [:akeybl] from comment #9)
> > (In reply to Jeff Muizelaar [:jrmuizel] from comment #8)
> > > Risk to taking this patch (and alternatives if risky): Canvas text could
> > > paint in the wrong place or not at all.
> > 
> > Would you consider this as having a very low probability of regression? If
> > not, we'd probably have this only land in FF14 and up given where we are in
> > the cycle.
> 
> I can do some testing tomorrow that should give an idea if this is likely to
> cause a regression. I should have a pretty good feeling after that.

I did some testing and this appears to be quite safe.
https://hg.mozilla.org/mozilla-central/rev/05f23d27c37a
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Comment on attachment 625109 [details] [diff] [review]
Avoid using CGContextSetTextMatrix

[Triage Comment]
Low risk fix for a regression in FF12, approved for Aurora 14 and Beta 13.
Attachment #625109 - Flags: approval-mozilla-beta?
Attachment #625109 - Flags: approval-mozilla-beta+
Attachment #625109 - Flags: approval-mozilla-aurora?
Attachment #625109 - Flags: approval-mozilla-aurora+
https://hg.mozilla.org/releases/mozilla-beta/rev/491fd5c11f42

Landed on beta because of deadline. Jeff can you take care of landing on aurora.
(In reply to Benoit Girard (:BenWa) from comment #14)
> https://hg.mozilla.org/releases/mozilla-beta/rev/491fd5c11f42
> 
> Landed on beta because of deadline. Jeff can you take care of landing on
> aurora.

I missed that the patch I imported didn't have an author field. It was written by Jeff, I did not review my own patch as the commit message says.
Whiteboard: [qa+]
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20100101 Firefox/13.0

Verified on Mac OS 10.6 with test case in comment 0 on F13 beta6. Could previously reproduce the issue in F12.
Verified on:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20100101 Firefox/14.0 beta 6

The text appears as described as above when the html file is loaded in browser.
Setting the flag to Verified on Firefox 14.
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:15.0) Gecko/20100101 Firefox/15.0

Verified on Mac OS 10.6 with test case in comment 0 on F15 beta1.
12/27/2013 This bug appears to be back in FF 26 for Mac. I filled text with a gradient in Safari, Opera and Chrome, all worked. In Firefox, the first color of a gradient is used to fill text, not the full gradient.
Ken, the testcase in this bug works fine for me in Firefox 26 on Mac.

Please file a new bug with your testcase that shows a problem and cc me on it?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: