Sign in to follow this  
visgotti

Render in node extremey slow

Recommended Posts

Hey obviously I know PIXI.js is meant for html5.. but I'm trying to have a server that records my game and converts it to a video. So to do this I need to render images of the current canvas at at least 20 fps

In the web browser this would be obviously simple.

The following code-

var timeNow = Date.now();
renderer.render(mainStage);
var timeAfter = Date.now();
console.log(timeAfter - timeNow)

 

In web browsers returns 1 ms

In node it returns anywhere from 180-300

I'm shimming PIXIjs with jsdom and node-canvas.. I don't understand the underlying technologies enough to understand why there's such a big difference.

Share this post


Link to post
Share on other sites

Both. Its always both for my posts.

Make a stage that is heavy for node-canvas, or just several drawImage calls how pixi CanvasRenderer does it. Present it to node-canvas guys, ask what's wrong with it. Also people were asking about node-webgl in pixijs issues, i dont know if anyone managed to run it there.

Share this post


Link to post
Share on other sites

I wouldn't say it's really too heavy

each bunny adds ~10 ms to the render.

for (var i = 0; i < 25; i++) {
    var bunny = new PIXI.Sprite(texture);
    bunny.anchor.set(0.5);
    bunny.x = (i % 5) * 40;
    bunny.y = Math.floor(i / 5) * 40;
    mainStage.addChild(bunny);
}

Share this post


Link to post
Share on other sites

fs.readFile('bunny.png', function(err, bunny) {
    img = new Image;
    img.src = bunny;

    var timeNow = Date.now();
    for(var i = 0; i < 500; i++) {
        ctx.drawImage(img, 50, 50, 50, 50);
    }

    var timeAfter = Date.now();
    console.log('time:', timeAfter-timeNow)
})

 

time: 807

Yep you're right. 800 ms for this.. Looks like I'll have to write something that spawns enough processes so I can render scenes for my targeted framerate.. No idea what other direction I can go in.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.