Frontory

Open code, practice, and notes →

Download source with English comments · for reading

GLSL · 26 Editing Failures and Context Recovery

Series contents · Technology map

Stage: Interaction, Postprocessing, and Cost Evaluation · Editable example · Storage ID: glsl-step-26

Goals and learning outcomes

Prerequisites

Continue using the output and records from Unit 25. Before experimenting with Editing Failures and Context Recovery, preserve the previous inputs and reference outputs.

Key concepts and explanations

Safe Replacement

Keeping the last working program when a new shader fails lets editing continue. Replace the active program only with a validated new program.

Context Lifetime

After WebGL context restoration, previous GPU resources must be recreated. Save source and CPU inputs to prepare a recreation path.

Practice setup

First check the execution scope guidance on the example screen. The following describes the environment needed to extend the assignment in a separate project. This document-guided exercise requires your own implementation using WebGL2 and GLSL ES 3.00 in a separate localhost project. First check the GLSL version of existing examples and avoid mixing in 1.00 syntax.

The linked example is a starting point. It does not implement every task below. Complete work beyond its supported scope in a separate project.

Practice tasks

  1. Compile and link a candidate program in editor.js, replacing the current program only on success.
  2. Enter a syntax error and check the error line and whether the existing display is retained.
  3. Handle webglcontextlost and webglcontextrestored, and list resources to recreate in README.

Variables to observe

VariableBaselineChangeExpected change / hypothesis
New sourcevalid sourcecontains a syntax errorExpect an error display while retaining the last working image.

Predictions in this table are not measured results. Change one condition at a time and record why the actual result differs.

Completion criteria

Self-check

  1. When should failed candidate shaders be deleted?
  2. Must UI state also be reset during context recovery?

Official references

Linked example and execution scope

Example source · Runtime environments and limits

Runs WebGL ShaderMaterial in the browser. Comparisons use a fixed 640×360 size; frame intervals are different from GPU time. The provided example only compiles an independent fragment shader, displays the raw compiler log, and retains the existing ShaderMaterial display. It does not install or replace a successful candidate program or implement context recovery.

Source code and records are not overwritten automatically. Resetting an existing example also preserves your notes.

Next learning

Previous: The Cost of Branches and Loops · Next: Quality Criteria and Regression Records

Open code, practice, and notes →