Different turning speed playground

Yo @Deltakosh or @sebavan … I got a funny timing thing happening in the playground between platform versions…

I have a javascript and typescript playgrounds that are the same code, But for some reason they turn at different rates… Like one of them is spinning fast, but the both have the same get delta time calculation.

Javascript Playground

And the Typescript Playground

Can you please take a look at why that could be happening

1 Like

They are the exact same for me :frowning: Can you try in incognito mode to be sure you have no cache

Javascript version rotates faster on my rig.

EDIT: closed the tabs, reopened and the issue is gone… wtf :slight_smile:

EDIT2: did the same again, javascript version is faster…

It seems to be an issue between js and ts, as the class is not initialized and is applied additionally. (If you run them simultaneously, the boxes running after them seem to run at twice the speed.)

There seems to be a difference when discarding or initializing pg in js and pg in ts. Is it related?
(speed is maintained correctly in multiple executions of ts + ts, js + js)

To be sure the issue is not comming from the base class, here are two PGs without external dependencies:

Start this first:
TS: https://playground.babylonjs.com/#5QY67Y#4

Second:
JS: https://playground.babylonjs.com/#TLH1QP#5

You get different rotation speeds.

Yeah… its weird… sometimes they are the same and sometimes one rotates faster.

1 Like

Indeed this is very weird. In fact on my side, it’s random in JS side. Launching the same JS on 2 different tabs doesn’t have the same result.

I have done a Playground with some UI to debug

What is weird is that I’m computing the REAL delta using Date.now() (just to make sure) and it seems that one cube is turning two times faster while the figures (deltaTime, etc) are exctly the same. I’m computing the real speed in Degrees/Second, and on both sides it’s about 80°/s :

Screencast from 18-07-2024 11:12:36

[EDIT] : It’s not exactly random in fact. Like @roland said, it seems that JS turns 2 times faster only when opened just after TS version. But, opening another JS after, is ok then. So you can end up with 2 JS versions running at differnent speed (GIF above), the one opened just after TS is 2 times faster

2 Likes

Open TS PG:

Open JS PG 3 times:

Only the first one runs faster. The second and the third are OK!

Open more JS PGs. All will be ok.

Open another TS PG:

Open multiple JS PGs. Again, only the first one opened after opening the TS PG rotates the cube faster…

:see_no_evil:

No PG works for me. They all crashed

Do we have a version without the toolkit? We need to understand if this is a problem with the PG or with the toolkit

EDIT:

both are running at the same speed on my device

These are rotating at the same speed. Using getAnimationRatio()

@RaananW @Deltakosh

All links at one place:

With toolkit:

JS runs faster on my machine.

Without toolkit:

Same speed.

Without toolkit using animationRatio:

Same speed.

ok so it is related to @MackeyK24 toolkit :slight_smile:

Yo @Deltakosh … I still get different speeds:

Demo Playground One Without Toolkit

AND

Demo Playground Two Without Toolkit

AND (Without GetAnimationRatio)

AND (With GetAnimationRatio)

They STILL run at diff speeds :frowning:

1 Like

Yo @roland , @RaananW and @Deltakosh … can you please test the playgrounds above again. You may have to try a few times. But I took a couple snapshots of the DOM console. No BABYLON.Toolkit stuff loaded at all. I made videos of both WITH and WITHOUT using GetAnimationRatio… It still rotates at different speeds

1 Like

wait wait wait!

Something is fishy

I have 2 animation requests per frame on TS:

1 Like

Ok I think we found it with @sebavan

Fix race condition by deltakosh · Pull Request #15303 · BabylonJS/Babylon.js (github.com)

3 Likes

Thank you so much to everyone for looking into this issue :slight_smile:

2 Likes

2 Likes