跪拜 Guibai
← All articles
Frontend

AI-Generated 3D Dashboard Crashed After 3 Days: The Performance Cliff AI Can't See

By 涛涛ing ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

AI code generation collapses the cost of a prototype, but the production ceiling is untouched: unbatched draw calls and leaked GPU memory still crash pages exactly as they did before AI. Teams shipping AI-generated front-ends need engineers who can inspect the output for resource lifecycle gaps, or they inherit a 2am production pager.

Summary

AI code generation cut the build time for a 3D warehouse dashboard from a month to ten minutes. The demo looked perfect: glowing shelves, particle effects, a rotating truck. In production, on day three, a 100k-record data push took the page down with a WebGL context lost error. The GPU memory was exhausted because the generated code recreated a new THREE.Mesh for each of 200 shuttle cars on every frame and never disposed the old ones. Each shelf also got its own emissive material and shadows, which turned into 200 independent draw calls.

The fix is a familiar Three.js workup: replace instanced objects with InstancedMesh to consolidate draw calls, manually dispose() all materials and geometries in the component's unmount hook, and throttle WebSocket updates to a 16ms per-frame merge instead of re-rendering on every push. That brought memory down to 300MB and held 60fps.

The deeper problem isn't that AI can't write Three.js. It's that AI-generated code optimizes for "it works" and skips resource lifecycle management. The crash exposes the true cost shift: writing the dashboard took ten minutes, but debugging the GPU failure took a full day, and the skill that mattered was reading the generated code for missing dispose() calls and unbatched draw calls.

Takeaways
— A ten-minute Claude-generated Vue3 + Three.js dashboard survived day one but crashed on day three when 100k live records hit.
— The failure showed up as a WebGL context lost error caused by GPU memory exhaustion.
— The generated code created a new THREE.Mesh for every one of 200 shuttle cars on each frame, and never disposed the old ones.
— Each shelf had its own emissive material and shadows, producing 200 separate draw calls.
— The component unmount never called dispose(), so the renderer kept running in the background, leaking memory.
— The fix: rewrite the scene with InstancedMesh, manually dispose() materials and geometries in onBeforeUnmount, and throttle WebSocket updates to a 16ms merge.
— After fixes: stable 60fps and memory around 300MB.
Conclusions

AI code generation optimizes for "it works" rather than "it scales", so the performance cliff between demo and production remains a human responsibility.

The cost shift is real: writing the dashboard took ten minutes, but debugging the crash took a full day, so the real bottleneck is the engineer's ability to read generated code for resource lifecycle issues.

Front-end engineering's moat is moving from API knowledge and animation skills to production failure prediction: knowing exactly where a page will die under load.

The claim that AI doesn't understand architecture is partly fair: it can produce working code, but it lacks the mental model of a production runtime, so the developer must supply that judgment.

Concepts & terms
WebGL context lost
The browser's WebGL context becomes unusable, typically from GPU memory exhaustion or a driver reset, causing a white screen and a console error.
InstancedMesh
A Three.js object that renders many instances of the same geometry in a single draw call, cutting GPU workload for repeated objects like shelves or vehicles.
Draw Call
A single command to the GPU to render geometry; many draw calls per frame slow rendering, so batching via instancing or merging reduces overhead.
From the discussion

The one substantive technical point is that the AI skipped all the performance-critical work — instanced rendering, manual disposal, and throttled updates — because the prompt never demanded them. The rest of the thread is mostly ridicule of the article's model version, treating Claude 3.5 Sonnet as ancient next to 5.5 and GPT-6. A single push for stress testing stands out as the only other concrete engineering takeaway.

— The WebGL crash is avoidable when the prompt explicitly forces three things: InstancedMesh for repetitive geometry, manual dispose() in component teardown, and requestAnimationFrame throttling of WebSocket updates; the AI won't do any of it unless told.
— The version mockery implies the article's example is stale — Claude 3.5 Sonnet is outclassed by newer models, so the performance cliff may be as much about model age as about prompt brevity.
— Load testing should have exposed the 100k-record crash before it happened in production.
— The divide is between treating the fix as a prompt-engineering problem (spell out the optimizations) versus treating it as a tooling problem (use a newer model or stress-test first).
Featured comments
PBitW 2 likes

Actually you just need to tell the AI to do it like this: Switch to instanced rendering: rewrite those 200 shuttle vehicles and several hundred shelves entirely with InstancedMesh. All rendering done in one draw call. Force manual cleanup: in the onBeforeUnmount lifecycle when the component unmounts, manually iterate all nodes to dispose() materials and geometries, and clear the renderer. Consolidate update frequency: don't re-render every time WebSocket pushes data. Instead use requestAnimationFrame and a throttle function, only merge and read the latest state every 16ms before updating. Then you can just go for it. The point is, if you don't tell it, it won't do it!

凌川江雪

4.5 is already an ancient model, and you're still on 3.5? Try GPT-6.

clench

Run a stress test then.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗