• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

decentraland / builder / 26915325312

03 Jun 2026 09:52PM UTC coverage: 51.631% (-0.1%) from 51.748%
26915325312

push

github

web-flow
fix: dispose Three.js renderer before Babylon.js screenshot to fix black wearable thumbnail (#3414)

* fix: dispose Three.js renderer before Babylon.js screenshot to fix black thumbnail

When a user selects a wearable category, updateThumbnailByCategory calls
getModelData with EngineType.BABYLON. This path first loads the model with
Three.js (creating a WebGL context) and then calls getScreenshot which creates
a second Babylon.js WebGL context — both active simultaneously.

Browsers limit active WebGL contexts to 8-16; having two new contexts alongside
the existing WearablePreview renderer can exhaust the limit, causing Babylon.js
to produce a blank/black screenshot that replaces the valid initial thumbnail.

Fix: dispose the Three.js renderer before calling getScreenshot so only one
WebGL context is active at a time. Also adds renderer cleanup to the catch block
to prevent context leaks when errors occur before the normal disposal point.

Closes https://github.com/decentraland/builder/issues/3413

* fix: dispose Babylon.js engine and scene after screenshot to prevent WebGL context leak

The getScreenshot function was never disposing the Babylon.js Engine or Scene
after taking a screenshot. Each call leaked a WebGL context, and after a few
uploads the browser's context limit (~8-16) was hit, causing subsequent
renders to silently produce empty thumbnails with no error.

Changes:
- Wrap getScreenshot body in try/finally to ensure Engine disposal
- Call scene.dispose() and engine.dispose() after screenshot is captured
- Add webglcontextlost event listener to detect context exhaustion and
  throw an explicit error instead of silently returning an empty image
- Guard canvas.removeChild with parentNode check for safety

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

2207 of 5477 branches covered (40.3%)

Branch coverage included in aggregate %.

0 of 83 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

7102 of 12553 relevant lines covered (56.58%)

33.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.75
/src/lib/getModelData.ts


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc