ParadoxMaster Posted November 25, 2018 Share Posted November 25, 2018 When I run my game in Firefox, after a few minutes of gaming or even just rotating the camera, the FPS in the game starts periodically drops. Of the stable 60 FPS drops by about a couple of seconds to 20-30 or even just stops. And it starts to happen more and more often. To fix this i need to reboot the browser, nothing else helps. I researched in the performance devtools in the browser and found that this is due by "Cycle Collection" process. ( Note: when I start recording performance, all FPS drops disappear, as if I restarted the browser. And I have to wait again for a while before they start. ) Has anyone else experienced this issue? What could it be? Another Firefox's WebGL bug? In Chrome and Edge i have no problems. Quote Link to comment Share on other sites More sharing options...
jerome Posted November 25, 2018 Share Posted November 25, 2018 As we have absolutely no idea about what your code actually does, it's quite difficult to answer ... Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 25, 2018 Share Posted November 25, 2018 Looks like you are instanciating items during the render loop adding pressure to the GC. Basically all the code in your render loop should not contain new keyword (of course a new happening every 10 seconds during a special event might be ok as long as it is not instanciating a big chunck of data) Quote Link to comment Share on other sites More sharing options...
ParadoxMaster Posted November 26, 2018 Author Share Posted November 26, 2018 Thanks for your replies! It's strange, but I can't reproduce this situation anymore... Without any significant changes in the code. I will describe in more detail what is happening in my code if it appears again. About my render loop: i use it for the vector calculations for moving my characters. Like this: move(deltaTime) { let ratio = deltaTime * this.FPS / 1000; let alignedEps = this.epsVector.scale(ratio * SPEED); let nextPosition = this._mesh.position.add(alignedEps); let nextNormale = this.targetPos.subtract(nextPosition).normalize(); if (Math.sign(nextNormale.x) != Math.sign(this.normale.x) && Math.sign(nextNormale.y) != Math.sign(this.normale.y) && Math.sign(nextNormale.z) != Math.sign(this.normale.z) ) { // Stop walking; if (this._walkPath.length == 0) { this._needMove = false; this.targetPos = this._mesh.position; this.blendAnim(this.walkAnim, this.idleAnim, BLEND_TIME.WalkToIdle); } else { this._calculate(); } } else { this._mesh.position = nextPosition; } } It's okay? Or may cause this problem? UPD: Now looking at it, I have guesses that a whole bunch of temporary vectors are being allocated here ... Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 26, 2018 Share Posted November 26, 2018 Yup ? you should allocate or several tmp vectors on load and then use only the vector method containing toRef like addToRef and so on. This will make the computation to an already existing vector vs allocating a new one increasing GC pressure. ParadoxMaster 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.