Atlaslog
Atlaslog / luma.gl / Tutorial / Debugging and performance
luma.gl · Tutorial

Debugging and performance

Quick answer

This tutorial shows how to surface silent GPU failures and then reduce cost. It enables the debug, debugShaders and debugFramebuffers Device options, reads shader logs with getCompilationInfoSync and getTranslatedSource, and inspects pipeline linkStatus. It labels commands with pushDebugGroup and reads pixels back through readBuffer plus readAsync. Performance advice covers capped pixel ratios, setNeedsRedraw, shared pipelines and instanced attributes. Readers can diagnose a black frame and find the real bottleneck.

Last verified 2026-11-03 · luma.gl 9.4 · Cite this page
Key points
Example
const device = await luma.luma.createDevice({
  type: 'webgl',
  adapters: [luma.webgl2Adapter],
  createCanvasContext: {
    canvas: document.getElementById('cv'),
    useDevicePixels: Math.min(window.devicePixelRatio, 2),
    autoResize: true
  },
  debug: true,
  debugShaders: 'errors',        // 'never' | 'errors' | 'warnings' | 'always'
  debugFramebuffers: true,       // 把帧缓冲缩略画到画布上
  onError: function (error, context) {
    console.error(error, context);
  }
});
const fs = device.createShader({ stage: 'fragment', source: fsSource });

if (fs.compilationStatus === 'error') {
  console.log(fs.getCompilationInfoSync());
  console.log(fs.getTranslatedSource());
}

const pipeline = device.createRenderPipeline({
  vs: vs,
  fs: fs,
  topology: 'triangle-list',
  bufferLayout: [{ name: 'positions', stepMode: 'vertex', format: 'float32x3' }]
});

console.log(pipeline.linkStatus);    // 'pending' | 'success' | 'error'
console.log(pipeline.isPending);
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Debugging and performance. https://www.jingweizhi.com/en/lumagl/tutorials/debugging-perf.html (accessed 2026-11-03).