Closed
Bug 1106756
Opened 9 years ago
Closed 9 years ago
Incorrect TypeError with Path2D.addPath
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: bugzilla.mozilla.org, Unassigned)
Details
Attachments
(1 file)
34.45 KB,
image/png
|
Details |
I'm getting "TypeError: Argument 1 of Path2D.addPath does not implement interface Path2D." when trying to cache Path2D objects generated from Strings. Generating the objects from scratch every time doesn't cause the exception, but it's more expensive. Is it disallowed to reuse path objects (in which case the exception is misleading) or should this work? I've made sure that I'm passing in the correct type with an instanceof check, see attached screenshot.
Updated•9 years ago
|
Flags: needinfo?(bugzilla.mozilla.org)
I tried but failed. Both methods involved are fairly trivial and I don't see anything that I might be doing wrong. The method generating the Path2D toCanvasPath: function() { if(this.pathCache instanceof Path2D) return this.pathCache return (this.pathCache = new Path2D(this.pathString())) }, The method consuming it: drawOnto: function(ctx) { let path = new Path2D() let paths = this.paths.forEach(p => {path.addPath(p.toCanvasPath())}) // ... then use path on ctx }, As far as I can tell this is always guaranteed to be a Path2D object, but to make doubly sure I added the type check (see screenshot) to ensure correctness and it still throws a TypeError. Could this be some JIT bug like bug 861947? Anything else I can do on my end to make sure I'm not holding it wrong?
Flags: needinfo?(bugzilla.mozilla.org)
javascript.options.baselinejit false javascript.options.ion false Problem still occurs, so probably not JIT-related.
Was a problem on my end after all. On some occasions the objects holding onto the cached paths were run through a deep clone algorithm which instantiated copies from the prototype without calling the constructor. That's why instanceof succeeded but it was not a real Path2D host object.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
Updated•9 years ago
|
Keywords: testcase-wanted
You need to log in
before you can comment on or make changes to this bug.
Description
•