The "LineSegments" object suffered a 1000% performance worsening after version 0.117.0 (problem also present in r142)
See original GitHub issueDescribe the bug
The performance of the LineSegments object has suffered a 1000% deterioration between version 0.117.0 and version 0.118.0. The performace degradation is present in all versions after 0.117.0. Even in the current version 0.142.0.
To Reproduce Create a LineSegments object with enough number of segments eg 400000, compare performance between version 0.117.0 and version 0.118.0.
Repeat the experiment with version 0.142.0
Steps to reproduce the behavior:
- Open chrome
- Go to release 0.118.0
- Open Inspector
- Go to performance tab
- Start registration
- Drag and zoom on canvas
- Stop registration
- Focus on gpu time frame
- Go to release 0.117.0
- Open Inspector
- Go to performance tab
- Start registration
- Drag and zoom on canvas
- Stop registration
- Focus on gpu time frame
- Compare point 8 and point 15
Code
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
});
renderer.setSize(window.innerWidth, window.innerHeight);
document.getElementById('app').appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000000
);
camera.position.x = 40;
camera.position.y = 25;
camera.position.z = 50;
const controls = new OrbitControls(camera, renderer.domElement);
controls.screenSpacePanning = false;
const geometry = new THREE.BufferGeometry();
geometry.setFromPoints(generateSegmment());
const material = new THREE.LineBasicMaterial({});
material.color = new THREE.Color(0xff0000);
const object = new THREE.LineSegments(geometry, material);
object.frustumCulled = false;
object.matrixAutoUpdate = false;
object.updateMatrixWorld(true);
scene.add(object);
animate();
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
function generateSegmment(): Array<THREE.Vector3> {
const segments: Array<THREE.Vector3> = [];
let k = 0;
for (let i = 0; i < 50000; i++) {
const pointA: THREE.Vector3 = new THREE.Vector3(i, 0, i - k);
const pointB: THREE.Vector3 = new THREE.Vector3(i, 0, i + 10);
const pointC: THREE.Vector3 = new THREE.Vector3(i - 10 - k, 0, i - k);
const pointD: THREE.Vector3 = new THREE.Vector3(i - 10 - k, 0, i + 10);
const pointE: THREE.Vector3 = new THREE.Vector3(i, 0, i + 10);
const pointF: THREE.Vector3 = new THREE.Vector3(i - 10 - k, 0, i + 10);
const pointG: THREE.Vector3 = new THREE.Vector3(i, 0, i - k);
const pointH: THREE.Vector3 = new THREE.Vector3(i - 10 - k, 0, i - k);
k += 2;
segments.push(
pointA,
pointB,
pointC,
pointD,
pointE,
pointF,
pointG,
pointH
);
}
return segments;
}
Live example
Expected behavior
Have the same performance as version 0.117.0
Screenshots
Please see gpu time 0.117.0
0.118.0
Platform:
- Device: [Desktop]
- OS: [MacOS]
- Browser: [Chrome]
- Three.js version: [r118, r119,r120,r121,r122,r123,r124,r125,r126,r140,r141,r142]
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
WebGL1Renderer now faster than WebGLRenderer after ...
After I update Brave, today, all my code was running really slow, from 59 fps to 14-15 fps The issue happened in both...
Read more >R142 (New York City Subway car) - Wikipedia
The R142 is the first successful model class of the newest generation or new technology (NTT) A Division cars for the New York...
Read more >Feature Request - Ability to append a local file - Hashicorp ...
The "LineSegments" object suffered a 1000% performance worsening after version 0.117.0 (problem also present in r142), 5, 2022-07-09, 2022-09-02.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://bugs.chromium.org/p/chromium/issues/detail?id=1245448
Just to confirm - @giuseppeLeggero are you getting this regression on Chrome >=100 on MacOS? Do you get the same regression on other browsers/Chrome 99/other OSes?