Jump to content

runRenderLoop and stopRenderLoop issues


Alex_on_the_web
 Share

Recommended Posts

Hello!
 
I am currently trying to make my runRenderLoop wrapper stupid-proof, so I want to stop it before issuing a new runRenderLoop() with my render callback.
 
Sadly, I find my preformance drop everytime I 'restart' the renderloop. The scene seems to be rendered as many times as I do calls on my wrapper. This is confirmed by visuals, as things get laggy, and by chrome's timeline, as it says Animation Frame Fired x N, where N increases everytime I restart.
 
Here is my wrapper function I call.
 

function startRender() {        if (!babylonEngine) {            init();        }        if (babylonEngine._runningLoop){            babylonEngine.stopRenderLoop();  // debugger shows I hit this point on restart, it goes into Babylon code, where it nullifies the callback, and clears this flag        }        var renderFunction = function (x) {            scene.render();        };        babylonEngine.runRenderLoop(renderFunction);    }    SCENEBABYLON.startRender = startRender;

 
 
I hope I've not missed anything trivial to begin with, and not wasting your time. Thanks for the answers :)

Link to comment
Share on other sites

It could be linked to timing. Because when you call scene.stopRenderLoop, a current render can be in progress. And because you reset a renderFunction right after the current registered render will see a renderFunction and so will continue to pull new frames

 

I'm not sure to be clear, alas :)

 

BTW, why not returning directly when startRender is called twice or more?

Link to comment
Share on other sites

BTW, why not returning directly when startRender is called twice or more?

 

 

You see, I thought, if there will be more things created, and / or arranged before starting the render (restarting the scene, so to say) it would be nice to restart the render, instead of just throwing away the restart request. But on a second thought, the render function will not really change, so it may as well stay in place. 

 

Thanks for the advice, I'll look into it

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...