Closed
Bug 1217031
Opened 10 years ago
Closed 10 years ago
createPattern throws NS_ERROR_NOT_AVAILABLE
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
RESOLVED
FIXED
mozilla49
| Tracking | Status | |
|---|---|---|
| firefox49 | --- | fixed |
People
(Reporter: tenner.joshua, Assigned: mkohler)
Details
(Whiteboard: gfx-noted)
Attachments
(3 files, 3 obsolete files)
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Steps to reproduce:
Use createPattern on an image with a dataurl in the same context.
var img = new Image();
img.src = 'data:image/gif;base64,...';
ctx.createPattern(img, 'no-repeat);
Visit: http://codepen.io/jtenner/pen/PPELad?editors=001
This is a codepen that creates a pattern from a dataurl (an asterisk) and fills a rect on the screen with the pattern.
Normally I would wait for the image to load, but chrome, IE, and opera don't seem to have a problem with this.
If the image is cached this problem doesn't occur. Repeated refreshes will show the asterisk but a hard refresh (ctrl-f5) reproduces the issue.
I happen to be maintaining a JavaScript library so I was just curious if this is normal proposed behavior for the browser?
Actual results:
Firefox throws: "NS_ERROR_NOT_AVAILABLE:"
Expected results:
It should create a fill pattern, I think.
Component: Untriaged → Canvas: 2D
Product: Firefox → Core
Summary: createPattern throws → createPattern throws NS_ERROR_NOT_AVAILABLE
Comment 2•10 years ago
|
||
Sounds like a spec question.
Flags: needinfo?(jmuizelaar)
Whiteboard: gfx-noted
Comment 3•10 years ago
|
||
It sounds like this behaviour is according to spec. See https://bugzilla.mozilla.org/show_bug.cgi?id=1164458#c6
Flags: needinfo?(jmuizelaar)
Updated•10 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Comment 5•10 years ago
|
||
Indeed. createPattern does exactly the same "Check the usability of the image argument" that drawImage does and the rest of the spec behavior is described in bug 1164458 comment 9.
That said, on "bad" return it should return null, not throw. So if we're throwing, that's clearly buggy per spec.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Comment 6•10 years ago
|
||
Of course the IDL for createPattern says it never returns null, so speccing it to return null is quite odd. ;)
Flags: needinfo?(annevk)
Comment 7•10 years ago
|
||
https://github.com/whatwg/html/issues/655 filed on the spec self-inconsistency wrt null.
Comment 8•10 years ago
|
||
Seems like the resolution here is that we'll change the specification to make that nullable. (ETA for that change is unknown, the more experienced editors try to leave "good first bug" issues alone.)
Flags: needinfo?(annevk)
| Reporter | ||
Comment 9•10 years ago
|
||
I just wanted to be clear:
(In reply to Boris Zbarsky [:bz] from comment #6)
> Of course the IDL for createPattern says it never returns null, so speccing
> it to return null is quite odd. ;)
This is exactly the problem :).
Also, I didn't mean to file a duplicate issue. I searched for createPattern and fillStyle to check and make sure I wasn't wasting people's time. Looks like this is being taken care of.
Thanks everyone!
| Assignee | ||
Comment 10•10 years ago
|
||
Spec has been changed to allow null return values: https://github.com/whatwg/html/commit/392c10a84c9fffc20d05157343d6f92fa55dc71d
Do I see this correctly that the thing to do here apart from changing the IDL (http://mxr.mozilla.org/mozilla-central/source/dom/webidl/CanvasRenderingContext2D.webidl#72) is to remove the following line? http://mxr.mozilla.org/mozilla-central/source/dom/canvas/CanvasRenderingContext2D.cpp#2124
| Assignee | ||
Comment 11•10 years ago
|
||
This also includes two removals of trailing whitespaces, I can take them out if you want me too.
Assignee: nobody → mkohler
Attachment #8732544 -
Flags: review?(bas)
| Assignee | ||
Updated•10 years ago
|
Attachment #8732544 -
Flags: review?(bas) → review?(gwright)
| Assignee | ||
Comment 12•10 years ago
|
||
Updated•10 years ago
|
Attachment #8732544 -
Flags: review?(gwright) → review+
| Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Comment 13•10 years ago
|
||
Please attach a patch with proper commit information before requesting checkin.
https://developer.mozilla.org/en-US/docs/Mercurial/Using_Mercurial#How_can_I_generate_a_patch_for_somebody_else_to_check-in_for_me.3F
Keywords: checkin-needed
| Assignee | ||
Comment 14•10 years ago
|
||
Attachment #8732544 -
Attachment is obsolete: true
Attachment #8744590 -
Flags: review+
| Assignee | ||
Updated•10 years ago
|
Whiteboard: gfx-noted → checkin-needed
| Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Whiteboard: checkin-needed
| Assignee | ||
Updated•10 years ago
|
Whiteboard: gfx-noted
Comment 15•10 years ago
|
||
For future reference, your commit messages should be explaining what the patch is actually doing, not just restating the problem they're solving.
| Assignee | ||
Comment 17•10 years ago
|
||
Attachment #8744590 -
Attachment is obsolete: true
Attachment #8744734 -
Flags: review?(bzbarsky)
Comment 18•10 years ago
|
||
Comment on attachment 8744734 [details] [diff] [review]
bug_1217031_goodcommitmessage.patch
r=me if security check failure is the only way res.GetSourceSurface() can return null. If there are other reasons (e.g. OOM), we should probably pass an Errorresult to either SurfaceFromElement or GetSourceSurface to throw an exception on it as needed.
Attachment #8744734 -
Flags: review?(bzbarsky) → review+
Updated•10 years ago
|
Keywords: checkin-needed
Comment 19•10 years ago
|
||
Keywords: checkin-needed
Comment 21•10 years ago
|
||
seems this caused https://treeherder.mozilla.org/logviewer.html#?job_id=27100597&repo=mozilla-inbound and so had to backed out
Comment 22•10 years ago
|
||
Comment 23•10 years ago
|
||
Looks like the test expectations needs to be updated; we're now passing the test when we used to fail it.
Note that this means we don't actually need to add another test. ;)
| Assignee | ||
Comment 24•10 years ago
|
||
| Assignee | ||
Comment 25•10 years ago
|
||
Attachment #8744734 -
Attachment is obsolete: true
Flags: needinfo?(me)
Attachment #8748292 -
Flags: review?(bzbarsky)
Comment 26•10 years ago
|
||
Comment on attachment 8748292 [details] [diff] [review]
0001-Bug-1217031-createPattern-should-not-throw-NS_ERROR_.patch
r=me
Attachment #8748292 -
Flags: review?(bzbarsky) → review+
| Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Comment 27•10 years ago
|
||
Keywords: checkin-needed
Comment 28•10 years ago
|
||
| bugherder | ||
Status: REOPENED → RESOLVED
Closed: 10 years ago → 10 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•