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

node 0.8.0 and toDataURL() #182

Closed
lpinca opened this issue Jun 27, 2012 · 8 comments
Closed

node 0.8.0 and toDataURL() #182

lpinca opened this issue Jun 27, 2012 · 8 comments

Comments

@lpinca
Copy link
Contributor

lpinca commented Jun 27, 2012

toDataURL() method seems to fail with node 0.8.0
Tried with live-clock example and got this error:

TypeError: Cannot call method 'toString' of undefined
    at Canvas.toDataURL (/home/luigi/Desktop/node-canvas/lib/canvas.js:174:37)
    at Server.<anonymous> (/home/luigi/Desktop/node-canvas/examples/live-clock.js:111:29)
    at Server.EventEmitter.emit (events.js:91:17)
    at HTTPParser.parser.onIncoming (http.js:1785:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
    at Socket.socket.ondata (http.js:1682:22)
    at TCP.onread (net.js:404:27)

It seems that toBuffer() return undefined.

@wavded
Copy link

wavded commented Jul 2, 2012

I'm getting something similar using 'nib' and gradient images: e.g. this fails:

background-image  : linear-gradient-image(200px, rgba(0,0,0,1), rgba(100,100,100,0.8))

with this error:

DEBUG: error:  500: TypeError: /home/wavded/Projects/arc/node_modules/nib/lib/nib/gradients.styl:148
   144|   start = start[1] or 'top'
   145|   grad = create-gradient-image(size, start)
   146|   stops = normalize-stops(stops)
   147|   add-color-stop(grad, stop[0], stop[1]) for stop in stops
 > 148|   'url(%s)' % gradient-data-uri(grad)
   149| 

Cannot call method 'toString' of undefined
    at ".humane" (/home/wavded/Projects/arc/assets/css/lib/humane.styl:12)
 stack=TypeError: /home/wavded/Projects/arc/node_modules/nib/lib/nib/gradients.styl:148
   144|   start = start[1] or 'top'
   145|   grad = create-gradient-image(size, start)
   146|   stops = normalize-stops(stops)
   147|   add-color-stop(grad, stop[0], stop[1]) for stop in stops
 > 148|   'url(%s)' % gradient-data-uri(grad)
   149| 

Cannot call method 'toString' of undefined
    at ".humane" (/home/wavded/Projects/arc/assets/css/lib/humane.styl:12)

    at Canvas.toDataURL (/home/wavded/Projects/arc/node_modules/canvas/lib/canvas.js:174:37)
    at Gradient.toDataURL (/home/wavded/Projects/arc/node_modules/nib/lib/nodes/gradient.js:158:17)
    at Evaluator.exports.dataURL (/home/wavded/Projects/arc/node_modules/nib/lib/nodes/gradient.js:61:32)
    at Evaluator.invokeBuiltin (/home/wavded/Projects/arc/node_modules/stylus/lib/visitor/evaluator.js:794:30)
    at Evaluator.visitCall (/home/wavded/Projects/arc/node_modules/stylus/lib/visitor/evaluator.js:341:16)
    at Evaluator.Visitor.visit (/home/wavded/Projects/arc/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/home/wavded/Projects/arc/node_modules/stylus/lib/visitor/evaluator.js:75:18)
    at Evaluator.visitBinOp (/home/wavded/Projects/arc/node_modules/stylus/lib/visitor/evaluator.js:396:20)
    at Evaluator.Visitor.visit (/home/wavded/Projects/arc/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/home/wavded/Projects/arc/node_modules/stylus/lib/visitor/evaluator.js:75:18), agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11, url=/css/layout.css?v=2.0.8, , v=2.0.8

@lpinca
Copy link
Contributor Author

lpinca commented Jul 3, 2012

For the moment i got rid of the problem by removing this line https://github.com/LearnBoost/node-canvas/blob/master/src/closure.h#L46

@wavded
Copy link

wavded commented Jul 9, 2012

That change fixed it for me, not sure if V8 will like it but :) Any thoughts @visionmedia ?

@ralphholzmann
Copy link

Bummer, that changed didn't fix it for me. Gonna have to comment out all the gradients in my app until this is fixed :(

@tj
Copy link
Contributor

tj commented Jul 11, 2012

it's not the freeing of the data itself, it's the GC hint to v8. this must be prematurely dereferencing the buffer or something, if i have time ill check this out soon but we're pretty busy with some other stuff ATM

@ralphholzmann
Copy link

Understood @visionmedia, I just disabled nib for now, hope to use it again once this issue gets resolved. Thanks.

@RandomEtc
Copy link
Contributor

I hit this problem too - in the meantime the async/callback versions of toBuffer and toDataURL seem to be working OK though.

@remoe
Copy link

remoe commented Jul 25, 2012

i have it also with node-0.8.3 and canvas-0.12.1:

TypeError: Cannot call method 'toString' of undefined
    at Canvas.toDataURL (/canvas/lib/canvas.js:174:37)

and it works with async version of toDataURL.

@tj tj closed this as completed in 0204157 Aug 8, 2012
tj added a commit that referenced this issue Aug 8, 2012
Fixes an issue related to a wrong variable type (#182)
tj added a commit that referenced this issue Aug 9, 2012
This reverts commit 0204157.
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

6 participants