Havok physics behavior is different on Android Chrome 106

Hello!

I’m trying to develop a physics based game with Android Chrome support, but physics calculations are wrong. Sphere doesn’t jump after collision and applying impulse results in very weak response. Problem happens only on Android Chrome 106.0.5249.126. Android Firefox, PC Chrome and PC Firefox are showing identical correct physics behaviours.

Repro scene:

To reproduce:

  1. Run scene on Android Chrome 106.0.5249.126
  2. Run the same scene in Android Firefox
  3. Compare behaviors with PC Chrome and Firefox

Scene is just default one from physics docs, but only the sphere jumpiness was increased for demo purposes.

Comparison videos:

P.S.
I can’t update the Chrome on Android to latest and retest, because update is not installing due to unsupported device or Google’s regional sanctions, so if I release my game, some players from my region will have this problem too, because they can’t update for the same reasons.

I tested on latest chrome and it works fine, but maybe @Cedric have an idea what could possibly happen here.

Is there any error in the console?

Looks like a delta time problem to me: a delta frame time value that is too high to have reliable physics.
Can you please log the frame timings ?PerformanceMonitor | Babylon.js Documentation
Also, try with fixed time step (60Hz ) instead of reporting time:

There are no errors

I’ve tried both values in BABYLON.HavokPlugin(true/false, havokInstance) but strange thing happened - it started working on Android Chrome and I can’t reproduce the wrong behaviour anymore. On my real project this doesn’t help (flipping true/false). Is this some sort of web caching behaviour only in the Playground? How can I repro the problem again?

I did not collect frame timings because I can’t repro anymore.

Update:
Clearing the cache helps. Then again I flip the value, do several page refreshes and it keeps working. Also sphere’s speed is different between true/false values.

as I said, I think the delta time between 2 frame is too high (no idea why).
at least, with a fixed time step, you are sure to get the good timing. on the other side if your framerate is too different on various devices, experience might not be great.

1 Like

Got the log while problem is reproducing with “true” using:

const perf = new BABYLON.PerformanceMonitor();
        perf.enable();
        scene.registerBeforeRender(()=>{
            perf.sampleFrame();
            console.log(perf.instantaneousFrameTime);
        });

Hope it helps. High values are caused by Chrome remote debug

babylon.js?t=1686211225622:1 Babylon.js v6.7.0 - WebGL2
babylon.playground.js?t=1686211225622:2 [Violation] Handling of 'touchstart' input event was delayed for 544 ms due to main thread being busy. Consider marking event handler as 'passive' to make the page more responsive.
[Violation] 'requestAnimationFrame' handler took <N>ms
[Violation] 'requestAnimationFrame' handler took <N>ms
[Violation] 'requestAnimationFrame' handler took <N>ms
[Violation] 'requestAnimationFrame' handler took <N>ms
[Violation] 'requestAnimationFrame' handler took <N>ms
babylon.js?t=1686211225622:1 Babylon.js v6.7.0 - WebGL2
babylon.playground.js?t=1686211225622:2 [Violation] 'requestIdleCallback' handler took 134ms
babylon.playground.js?t=1686211225622:2 [Violation] 'requestIdleCallback' handler took 92ms
babylon.js?t=1686211225622:1 Babylon.js v6.7.0 - WebGL2
VM1512:20 0
VM1512:20 277.19999998807907
VM1512:20 26.30000001192093
VM1512:20 11.900000035762787
VM1512:20 34.59999996423721
VM1512:20 37.19999998807907
VM1512:20 47.90000003576279
VM1512:20 41.39999997615814
VM1512:20 47.40000003576279
VM1512:20 35.19999998807907
VM1512:20 30
VM1512:20 36.19999998807907
VM1512:20 25
VM1512:20 57.69999998807907
VM1512:20 54.69999998807907
VM1512:20 9.700000047683716
VM1512:20 29.899999976158142
VM1512:20 27.899999976158142
VM1512:20 42.60000002384186
VM1512:20 35.80000001192093
VM1512:20 26.399999976158142
VM1512:20 42.40000003576279
VM1512:20 26.399999976158142
VM1512:20 36.39999997615814
VM1512:20 26.700000047683716
VM1512:20 38
VM1512:20 32.799999952316284
VM1512:20 37.10000002384186
VM1512:20 28.69999998807907
VM1512:20 33.40000003576279
VM1512:20 31.899999976158142
VM1512:20 32.10000002384186
VM1512:20 33
VM1512:20 24.099999964237213
VM1512:20 51
VM1512:20 32.10000002384186
VM1512:20 30
VM1512:20 34
VM1512:20 29.19999998807907
VM1512:20 24.100000023841858
VM1512:20 32.59999996423721
VM1512:20 45.10000002384186
VM1512:20 31.899999976158142
VM1512:20 33.60000002384186
VM1512:20 31.899999976158142
VM1512:20 40.10000002384186
VM1512:20 28.899999976158142
VM1512:20 39.19999998807907
VM1512:20 26.700000047683716
VM1512:20 23.399999976158142
VM1512:20 37
VM1512:20 37.30000001192093
VM1512:20 31.5
VM1512:20 24.099999964237213
VM1512:20 31.5
VM1512:20 39
VM1512:20 30.600000023841858
VM1512:20 28.5
VM1512:20 31.899999976158142
VM1512:20 28.400000035762787
VM1512:20 39.69999998807907
VM1512:20 35.60000002384186
VM1512:20 31.69999998807907
VM1512:20 50.69999998807907
VM1512:20 34
VM1512:20 35.5
VM1512:20 40.89999997615814
VM1512:20 37.10000002384186
VM1512:20 42.39999997615814
VM1512:20 43.40000003576279
VM1512:20 36.39999997615814
VM1512:20 39.80000001192093
VM1512:20 26.899999976158142
VM1512:20 37.40000003576279
VM1512:20 32.89999997615814
VM1512:20 38.60000002384186
VM1512:20 30
VM1512:20 34
VM1512:20 34.69999998807907
VM1512:20 32.80000001192093
VM1512:20 37.59999996423721
VM1512:20 33.80000001192093
VM1512:20 31.69999998807907
VM1512:20 38.5
VM1512:20 34.700000047683716
VM1512:20 31.5
VM1512:20 34.299999952316284
VM1512:20 33.200000047683716
VM1512:20 36.69999998807907
VM1512:20 32.30000001192093
VM1512:20 37.799999952316284
VM1512:20 30.5
VM1512:20 32.30000001192093
VM1512:20 33.30000001192093
VM1512:20 29.899999976158142
VM1512:20 39.200000047683716
VM1512:20 31.299999952316284
VM1512:20 28.200000047683716
VM1512:20 34.39999997615814
VM1512:20 31.30000001192093
VM1512:20 26.80000001192093
VM1512:20 37.799999952316284
VM1512:20 34.200000047683716
VM1512:20 33.19999998807907
VM1512:20 36.30000001192093
VM1512:20 30.799999952316284
VM1512:20 35.10000002384186
VM1512:20 37.10000002384186
VM1512:20 31.899999976158142
VM1512:20 36.10000002384186
VM1512:20 32.39999997615814
VM1512:20 35.69999998807907
VM1512:20 31.19999998807907
VM1512:20 34.5
VM1512:20 30.400000035762787
VM1512:20 33.89999997615814
VM1512:20 34.60000002384186
VM1512:20 34.59999996423721
VM1512:20 33.60000002384186
VM1512:20 32.30000001192093
VM1512:20 55
VM1512:20 24.19999998807907
VM1512:20 31.69999998807907
VM1512:20 24.80000001192093
VM1512:20 25.600000023841858
VM1512:20 33.89999997615814
VM1512:20 32.89999997615814
VM1512:20 20.200000047683716
VM1512:20 46.39999997615814
VM1512:20 20.80000001192093
VM1512:20 15.199999988079071
VM1512:20 20
VM1512:20 15.199999988079071
VM1512:20 19.100000023841858
VM1512:20 27.899999976158142
VM1512:20 19
VM1512:20 29.5
VM1512:20 32.40000003576279
VM1512:20 32
VM1512:20 32.299999952316284
VM1512:20 26
VM1512:20 38
VM1512:20 36.700000047683716
VM1512:20 29.69999998807907
VM1512:20 38.09999996423721
VM1512:20 33.5
VM1512:20 30.600000023841858
VM1512:20 37.5
VM1512:20 34.80000001192093
VM1512:20 32.80000001192093
VM1512:20 31.69999998807907
VM1512:20 39.80000001192093
VM1512:20 31.19999998807907
VM1512:20 39.89999997615814
VM1512:20 35.19999998807907
VM1512:20 22.200000047683716
VM1512:20 31.5
VM1512:20 32.299999952316284
VM1512:20 36.90000003576279
VM1512:20 32.80000001192093
VM1512:20 29.099999964237213
VM1512:20 31.400000035762787
VM1512:20 41.299999952316284
VM1512:20 30.5
VM1512:20 35.10000002384186
VM1512:20 29.69999998807907
VM1512:20 36.5
VM1512:20 34.30000001192093
VM1512:20 36.89999997615814
VM1512:20 30.700000047683716
VM1512:20 29.299999952316284
VM1512:20 38.30000001192093
VM1512:20 49.5
VM1512:20 25.19999998807907
VM1512:20 9.5
VM1512:20 15.5
VM1512:20 30.100000023841858
VM1512:20 30.5
VM1512:20 17.899999976158142
VM1512:20 15.900000035762787
VM1512:20 15.899999976158142
VM1512:20 16.100000023841858
VM1512:20 28
VM1512:20 32.80000001192093
VM1512:20 39.5
VM1512:20 28.5
VM1512:20 56
VM1512:20 32.299999952316284
VM1512:20 34.30000001192093
VM1512:20 33.10000002384186
VM1512:20 36.19999998807907
VM1512:20 32.69999998807907
VM1512:20 36.40000003576279
VM1512:20 34.5
VM1512:20 34.69999998807907
VM1512:20 42.30000001192093
VM1512:20 37.19999998807907
VM1512:20 31.5
VM1512:20 34.69999998807907
VM1512:20 38.39999997615814
babylon.js?t=1686211225622:1 Babylon.js v6.7.0 - WebGL2
VM1747:20 0
VM1747:20 222.80000001192093
VM1747:20 16.099999964237213
VM1747:20 10.700000047683716
VM1747:20 27
VM1747:20 35.5
VM1747:20 39.799999952316284
VM1747:20 25.700000047683716
VM1747:20 31.5
VM1747:20 34.299999952316284
VM1747:20 31.80000001192093
VM1747:20 34.60000002384186
VM1747:20 31.599999964237213
VM1747:20 41.60000002384186
VM1747:20 38.30000001192093
VM1747:20 30.099999964237213
VM1747:20 33.5
VM1747:20 33.30000001192093
VM1747:20 34
VM1747:20 28
VM1747:20 36.60000002384186
VM1747:20 31.30000001192093
VM1747:20 35.89999997615814
VM1747:20 34.5
VM1747:20 37.10000002384186
VM1747:20 30.099999964237213
VM1747:20 31.30000001192093
VM1747:20 34.80000001192093
VM1747:20 37.09999996423721
VM1747:20 31.80000001192093
VM1747:20 31.19999998807907
VM1747:20 39.30000001192093
VM1747:20 26.80000001192093
VM1747:20 38.5
VM1747:20 28
VM1747:20 33.60000002384186
VM1747:20 32.39999997615814
VM1747:20 28.5
VM1747:20 31.899999976158142
VM1747:20 40
VM1747:20 37.700000047683716
VM1747:20 31.19999998807907
VM1747:20 27
VM1747:20 34.59999996423721
VM1747:20 40.5
VM1747:20 35
VM1747:20 27.200000047683716
VM1747:20 34.59999996423721
VM1747:20 29.5
VM1747:20 35.19999998807907
VM1747:20 35.80000001192093
VM1747:20 30.100000023841858
VM1747:20 37.30000001192093
VM1747:20 23.399999976158142
VM1747:20 30.600000023841858
VM1747:20 34.59999996423721
VM1747:20 36.30000001192093
VM1747:20 33
VM1747:20 33.60000002384186
VM1747:20 38.5
VM1747:20 33
VM1747:20 33.59999996423721
VM1747:20 25
VM1747:20 31.100000023841858
VM1747:20 38.09999996423721
VM1747:20 29.900000035762787
VM1747:20 32.80000001192093
VM1747:20 34
VM1747:20 26.599999964237213
VM1747:20 39.19999998807907
VM1747:20 37
VM1747:20 40.10000002384186
VM1747:20 22.30000001192093
VM1747:20 27.899999976158142
VM1747:20 37.30000001192093
VM1747:20 31
VM1747:20 31.600000023841858
VM1747:20 34.09999996423721
VM1747:20 33.40000003576279
VM1747:20 34.59999996423721
VM1747:20 31.900000035762787
VM1747:20 34.5
VM1747:20 31.399999976158142
VM1747:20 37.80000001192093
VM1747:20 29.899999976158142
VM1747:20 36.60000002384186
VM1747:20 30.899999976158142
VM1747:20 33.5
VM1747:20 32.40000003576279
VM1747:20 32.69999998807907
VM1747:20 37.59999996423721
VM1747:20 34.5
VM1747:20 31.5
VM1747:20 37.10000002384186
VM1747:20 28.19999998807907
VM1747:20 34.30000001192093
VM1747:20 32.10000002384186
VM1747:20 33.09999996423721
VM1747:20 33
VM1747:20 40.40000003576279
VM1747:20 26.19999998807907
VM1747:20 32.80000001192093
VM1747:20 92.09999996423721
VM1747:20 11.5
VM1747:20 13.5
VM1747:20 22.80000001192093
VM1747:20 36.19999998807907
VM1747:20 27.900000035762787
VM1747:20 19.5
VM1747:20 14.599999964237213
VM1747:20 21.400000035762787
VM1747:20 48
VM1747:20 20.599999964237213
VM1747:20 24
VM1747:20 45.80000001192093
VM1747:20 40.19999998807907
VM1747:20 34.69999998807907
VM1747:20 32.80000001192093
VM1747:20 33.60000002384186
VM1747:20 35
VM1747:20 33.59999996423721
VM1747:20 40.40000003576279
VM1747:20 31
VM1747:20 38.89999997615814
VM1747:20 38
VM1747:20 37.90000003576279
VM1747:20 39.09999996423721
VM1747:20 32.80000001192093
VM1747:20 34.69999998807907
VM1747:20 34.80000001192093
babylon.js?t=1686211225622:1 Babylon.js v6.7.0 - WebGL2
VM1982:20 0
VM1982:20 217.39999997615814
VM1982:20 34.30000001192093
VM1982:20 19.30000001192093
VM1982:20 15.800000011920929
VM1982:20 31.599999964237213
VM1982:20 34.80000001192093
VM1982:20 35.19999998807907
VM1982:20 33.30000001192093
VM1982:20 36.80000001192093
VM1982:20 32.5
VM1982:20 32.80000001192093
VM1982:20 35
VM1982:20 33.09999996423721
VM1982:20 33.30000001192093
VM1982:20 33.40000003576279
VM1982:20 39.09999996423721
VM1982:20 28.5
VM1982:20 34.40000003576279
VM1982:20 32
VM1982:20 40.09999996423721
VM1982:20 33
VM1982:20 34.10000002384186
VM1982:20 36.89999997615814
VM1982:20 32.90000003576279
VM1982:20 34.19999998807907
VM1982:20 35
VM1982:20 32.09999996423721
VM1982:20 31.900000035762787
VM1982:20 34.5
VM1982:20 37.09999996423721
VM1982:20 32.90000003576279
VM1982:20 34.89999997615814
VM1982:20 41.80000001192093
VM1982:20 28.30000001192093
VM1982:20 35.89999997615814
VM1982:20 40.69999998807907
VM1982:20 29.5
VM1982:20 37.40000003576279
VM1982:20 32.5
VM1982:20 29.899999976158142
VM1982:20 34.80000001192093
VM1982:20 31.100000023841858
VM1982:20 36.5
VM1982:20 36.19999998807907
VM1982:20 35.39999997615814
VM1982:20 29.80000001192093
VM1982:20 38.5
VM1982:20 31.30000001192093
VM1982:20 35.59999996423721
VM1982:20 31.600000023841858
VM1982:20 42.39999997615814
VM1982:20 28.900000035762787
VM1982:20 33
VM1982:20 39.30000001192093
VM1982:20 32
VM1982:20 32.799999952316284
VM1982:20 37.5
VM1982:20 31.700000047683716
VM1982:20 33.09999996423721
VM1982:20 38.90000003576279
VM1982:20 34.799999952316284
VM1982:20 29.100000023841858
VM1982:20 30.600000023841858
VM1982:20 34.39999997615814
VM1982:20 33.39999997615814
VM1982:20 31.700000047683716
VM1982:20 37.19999998807907
VM1982:20 30
VM1982:20 34.89999997615814
VM1982:20 32.30000001192093
VM1982:20 32
VM1982:20 34.30000001192093
VM1982:20 29.80000001192093
VM1982:20 35.39999997615814
VM1982:20 34.30000001192093
VM1982:20 39.30000001192093
VM1982:20 26.69999998807907
VM1982:20 34.5
VM1982:20 35
VM1982:20 35.89999997615814
VM1982:20 34.40000003576279
VM1982:20 42.19999998807907
VM1982:20 23.899999976158142
VM1982:20 40.40000003576279
VM1982:20 36.299999952316284
VM1982:20 33.700000047683716
VM1982:20 33.799999952316284
VM1982:20 33.5
VM1982:20 34.5
VM1982:20 36.60000002384186
VM1982:20 35.5
VM1982:20 32
VM1982:20 36.19999998807907
VM1982:20 40.30000001192093
VM1982:20 23
VM1982:20 34.10000002384186
VM1982:20 34.799999952316284
VM1982:20 35.90000003576279
VM1982:20 33.09999996423721
VM1982:20 38.700000047683716
VM1982:20 29
VM1982:20 37.39999997615814
VM1982:20 36
VM1982:20 34.80000001192093
VM1982:20 35.39999997615814
VM1982:20 43.30000001192093
VM1982:20 34.39999997615814
VM1982:20 36.5
VM1982:20 28.80000001192093
VM1982:20 38
VM1982:20 35
VM1982:20 27.30000001192093
VM1982:20 35.19999998807907
VM1982:20 33.19999998807907
VM1982:20 41.200000047683716
VM1982:20 31.5
VM1982:20 45
VM1982:20 22.899999976158142
VM1982:20 27.399999976158142
VM1982:20 35.40000003576279
VM1982:20 34.89999997615814
VM1982:20 35.5
VM1982:20 41.5
VM1982:20 23.80000001192093
VM1982:20 42.30000001192093
VM1982:20 34.19999998807907
VM1982:20 32.60000002384186
VM1982:20 29.099999964237213
VM1982:20 32.5
VM1982:20 42.30000001192093
VM1982:20 32.89999997615814
VM1982:20 34
VM1982:20 29.80000001192093
VM1982:20 36.60000002384186
VM1982:20 35.89999997615814
VM1982:20 31.19999998807907
VM1982:20 32
VM1982:20 34.90000003576279
VM1982:20 33.09999996423721
VM1982:20 33.90000003576279
VM1982:20 32.89999997615814
VM1982:20 35.30000001192093
VM1982:20 34.60000002384186
VM1982:20 34.89999997615814
VM1982:20 41.60000002384186
VM1982:20 28.799999952316284
VM1982:20 37
VM1982:20 34
VM1982:20 33.10000002384186
VM1982:20 32.10000002384186
VM1982:20 36.39999997615814
VM1982:20 34.60000002384186
VM1982:20 35.799999952316284
VM1982:20 31.900000035762787
VM1982:20 34.30000001192093
VM1982:20 34.89999997615814
VM1982:20 29.899999976158142
VM1982:20 32.10000002384186
VM1982:20 32
VM1982:20 35.39999997615814
VM1982:20 35.10000002384186
VM1982:20 29.100000023841858
VM1982:20 35
VM1982:20 32.89999997615814
VM1982:20 32.19999998807907
VM1982:20 34.40000003576279
VM1982:20 37.19999998807907
VM1982:20 31.30000001192093
VM1982:20 33.69999998807907
VM1982:20 34
VM1982:20 31.30000001192093
VM1982:20 32.89999997615814
VM1982:20 34.19999998807907
VM1982:20 35.10000002384186
VM1982:20 34
VM1982:20 33.30000001192093
VM1982:20 32.5
VM1982:20 34.19999998807907
VM1982:20 34.19999998807907
VM1982:20 35.30000001192093
VM1982:20 29.899999976158142
VM1982:20 35.5
VM1982:20 33.69999998807907
VM1982:20 42
VM1982:20 33.30000001192093
VM1982:20 32.5
VM1982:20 39.60000002384186
VM1982:20 30.80000001192093
VM1982:20 33
VM1982:20 38.299999952316284
VM1982:20 33.80000001192093
VM1982:20 34.69999998807907
VM1982:20 33.30000001192093
VM1982:20 33.60000002384186
VM1982:20 32.39999997615814
VM1982:20 33.40000003576279
VM1982:20 34.299999952316284
VM1982:20 34.700000047683716
VM1982:20 31.799999952316284
VM1982:20 40.80000001192093
VM1982:20 28.100000023841858
VM1982:20 40.5
VM1982:20 32.30000001192093
VM1982:20 34
VM1982:20 35
VM1982:20 35.299999952316284
VM1982:20 31.200000047683716
VM1982:20 34.799999952316284
VM1982:20 35.80000001192093
VM1982:20 30.600000023841858
VM1982:20 34.80000001192093
VM1982:20 33.19999998807907
VM1982:20 32.19999998807907
VM1982:20 33.5
VM1982:20 36.80000001192093
VM1982:20 30
VM1982:20 36.80000001192093
VM1982:20 40.09999996423721
VM1982:20 34.10000002384186
VM1982:20 31
VM1982:20 43.89999997615814
VM1982:20 32.60000002384186
VM1982:20 48.89999997615814
VM1982:20 24.900000035762787
VM1982:20 16.5
VM1982:20 21.5
VM1982:20 22.19999998807907
VM1982:20 26.80000001192093
VM1982:20 20
VM1982:20 30
VM1982:20 19
VM1982:20 30.599999964237213
VM1982:20 18.19999998807907
VM1982:20 23.600000023841858
VM1982:20 28
VM1982:20 31.19999998807907
VM1982:20 18.19999998807907
VM1982:20 31
VM1982:20 21.5
VM1982:20 31
VM1982:20 25.100000023841858
VM1982:20 25.899999976158142
VM1982:20 31.100000023841858
VM1982:20 20.80000001192093
VM1982:20 28.5
VM1982:20 23.19999998807907
VM1982:20 28.100000023841858
VM1982:20 24.599999964237213
VM1982:20 25.900000035762787
VM1982:20 32.19999998807907
VM1982:20 17.69999998807907
VM1982:20 31.399999976158142
VM1982:20 20.600000023841858
VM1982:20 28.600000023841858

frame time is very volatile …between 60ms and 9!!
Do you have some app running in the background that can explain the CPU usage?

Yes, Chrome remote debug connected over cable lowers FPS, so those logs are not so helpful.

can you test this PG ? https://playground.babylonjs.com/#MDVCGR#8

Sure, I’ve cleared the browser’s cache, run the example 3 times, then refreshed and re-run again. Each time there were none bounces from the ground. Chrome remote debug was disabled.

Then, I’ve tried false and hit run. The first 2 times it wasn’t working. Then on each subsequent try it started jumping. So i needs false and several clicks to Run.

After, I’ve reverted to true and hit run several times, error didn’t come back. So I’m unsure what is happening in PG. In my real project both true/false doesn’t help, and I have no run/reload feature coded, so I can’t fix.

Might be related to wasm precompilation that’s taking a bunch of time (200ms visible in the log).
Does it happen with ammo/cannon?

I’m sorry, I’ve tried copypasting from other PG the following, it works there, but not in my PG

let physicsPlugin = new BABYLON.AmmoJSPlugin();
scene.enablePhysics(BABYLON.Vector3.Zero(),physicsPlugin);

but it throws

caught (in promise) Error: Plugin version is incorrect. Expected version 2.

I do not understand why other PG works and mine do not.

try this 1

1 Like

This one simulates the same on all 4 browsers tested by me, only FPS differs, but bounciness is perfectly the same.

My guess is wasm compilation/optimization is not suitable for your platform. I would stick with ammo until chrome gets updated in your region.

2 Likes

Thanks, I was finally able to port my project to ammo.

1 Like