The 16-context limit
Chromium's limit; other browsers differ. The devtools console also shows the browser's warning.
The GPU can take a canvas's WebGL context away while the page is open. three.js rebuilds its own objects when it comes back, but anything you drew once, or made with your own WebGL code, is empty until you rebuild it.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 4 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write the two handlers for a page whose render loop is loop: stop it when the context is lost, start it when restored.
A scene paints a static reflection into target once at load. Add the code that keeps it correct after a restore.
Explain it without notes
Which things does three.js bring back after webglcontextrestored, and which do you have to rebuild? Give two examples of each.
Why is calling event.preventDefault() in the lost handler important?
Console
Nothing logged yet.Expected console output
contexts made: 20 | lost: 4 | the oldest ones: 0, 1, 2, 3
the newest (19) is alive: true