Javascript behaves differently when Chrome console is open/closed

The other day I found a massive bug in Morterra: Scene.pick() in runRenderLoop blocking Socket.io packets?

Since then, I’ve discovered that the two functions that I originally thought were causing my problems, aren’t at all the cause of the problem. The game has produced the same lag even with those commented out, and has not lagged with them fully functioning…

This puts me back at square 1.

There is a mystery lag that occurs when I rotate the camera, I can’t narrow it down to anything in my code, and the only thing that fixes it is if I have the Chrome DevTools/console open, it never happens.

I’ve found some loosely related topics online, with similar mystery bugs that disappear with the console open, but none have had any insight as to why or what can fix it.

Does anyone know what differences there are with running javascript code if the console is open or closed? Or any ideas as to what may be causing this problem would be greatly appreciated!

No idea, sorry, but have you tried in another browser to see if the problem exists there also?

1 Like

Yeah, but it’s hard to say because Firefox just lags terribly in general, and Edge uses the same engine as Chrome now so it has the same issue.

Maybe it’s something related to GC? When the dev console is opened, maybe Chrome is doing GC differently/more/less often…

2 Likes

I have only seen input being higher frequency when the devtools are open and i wonder if it could be the reason of your slowdown if you do anything complex with them ?

1 Like

Hmm, you might be on to something. What did you use to see the frequency of inputs?

I have just noticed it while creating a drawing app :slight_smile:

Gotcha.

One thing I realized is that scene.picking shouldn’t be the cause, because the problem only occurs on camera rotate. If you walk straight forward it won’t lag, but scene.pick() is still running every render loop, without any lag. If scene.pick was causing the lag, it would just always lag. Also, scene.pick only takes like 2 millis.

I have placed no code in my scene.onPointerMove(), which would be where this type of lag stems from (I’m assuming).

And still, having the dev console open completely fixes the problem.

Absolutely bizarre :frowning:

I’ve also noticed significant performance issues with Chrome Devtools open in the game I’m building

The memory usage goes up each page refresh until I close the tab and open it again

It got worse when I started using lots of workers and when using > 100 MB of ram

This is because they need to turn off a lot of JIT optimizations for the debugger to work

3 Likes

Wouldn’t the dev console running without some JIT optimizations slow down the browser? My issue is that the browser lags with the console closed.

I think it makes sense to me that browser lags if dev console is open but ultimately this is a question for google team