# Game runs at different speeds in Chrome versus Firefox

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){

p.keyEvents();

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 );
p.socket.emit('players',foundPlayers);

foundBodies.players=[];

}

world.Step(
1 / 60   //frame-rate
,  8       //velocity iterations
,  3       //position iterations
);

if(deletePlayerIds.length>0){
deletePlayer();
}

world.ClearForces();
}

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?

• Are you using service workers? – Theraot Sep 20 '19 at 15:16
• no, why . But just found the solution by applying delta time instead of fixed step – JustStarted Sep 21 '19 at 13:51
• 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. – Theraot Sep 21 '19 at 14:06