eendeego / node-openvg-canvas

Canvas implementation on top of node-openvg
179 stars 25 forks source link

How to destroy the canvas? (Bug when using together with omxplayer) #19

Open diogoviannaaraujo opened 10 years ago

diogoviannaaraujo commented 10 years ago

Hi,

I have been using your library intensively in the last days, i have noticed a problem that only happens in a case:

omxplayer gets some strange flickerings, when i close node it stops, if vgSwapBuffer is called sometimes it happens more, if i only get the context and don't draw anything it does not happen. I ve tried so many ways to delete the canvas object and the context but it still keeps happening. It there a right way to release the openvg canvas? Does anyone might know what may cause this?

eendeego commented 10 years ago

I don't know if this makes any sense in your use case, but, can you try calling openvg's shutdown function ?

var vg = require('openvg');
vg.shutdown();
diogoviannaaraujo commented 10 years ago

I did that yesterday night, but since i did not have the openvg package i edited openvg-canvas to attach the vg object to the canvas object, like canvas.vg. Is that worse for performance? is there a way to use load the openvg inside node openvg-canvas?

And about the problem, doing vg.finish stopped the problem with omxplayer, after the video is played i just instance a new canvas and start from there. Is better for i use shutdown() instead of finish()?

Thanks a lot

eendeego commented 10 years ago

I think you can just add openvg to your project and require it directly. Everyone will be using the same module.

Currently vg.finish just calls shutdown (https://github.com/luismreis/node-openvg/blob/master/openvg.js#L747). But you should actually be using it instead of shutdown (my bad), because I'm planning to move mode initialization/shutdown from C++ space to JS, thus, eventually, the proper shutdown code will be there.

diogoviannaaraujo commented 10 years ago

Nice! Thank u very much!

diogoviannaaraujo commented 10 years ago

hey @luismreis, one more question, after i do vg.finish and recreate the canvas, i can draw shapes on it but i can't draw text, do you know why?

eendeego commented 10 years ago

I'd have to investigate a bit. There's no obvious reason.