I am using Box2D for physics on the server side. Player position is updated on the server, so there is nothing the client can do except give input.

But running game in Chrome only, the player moves faster as compared to running in Firefox only.

If running in both browsers (one player in each browser), then the game in both browsers runs at the speed at which it runs in Chrome.

Using this update loop:

function update() {

    for(let p of players){

        if(p.dead) continue ;


        aabb.lowerBound.Set( p.body.GetPosition().x-p.s_w/(2*scale),p.body.GetPosition().y-p.s_h/(2*scale) );//top left
        aabb.upperBound.Set( p.body.GetPosition().x+p.s_w/(2*scale),p.body.GetPosition().y+p.s_h/(2*scale) );//bottom right 
        world.QueryAABB( ReportFixture , aabb , p.id );



       1 / 60   //frame-rate
        ,  8       //velocity iterations
        ,  3       //position iterations



setInterval(update, 1000/60);//to call update loop

I have read that for Box2D there is no need to apply a delta.

What could be the reason for different speeds, and how it can be resolved?

  • \$\begingroup\$ Are you using service workers? \$\endgroup\$ – Theraot Sep 20 '19 at 15:16
  • 1
    \$\begingroup\$ no, why . But just found the solution by applying delta time instead of fixed step \$\endgroup\$ – JustStarted Sep 21 '19 at 13:51
  • \$\begingroup\$ If I understood correctly, the problem happens when you have two instances in firefox. As in, something from one instance wer eaffecting the other. Something that would be different in chrome. Service workers would fill the bitll. Since, by what you say, that is not the problem...You should find Jake Archibald: In The Loop - JSConf.Asia useful. \$\endgroup\$ – Theraot Sep 21 '19 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.