This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

HTMLCanvasElement: событие webglcontextlost

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨июль 2015 г.⁩.

Событие webglcontextlost WebGL API вызывается когда User agent обнаруживает, что буфер, связанный с WebGLRenderingContext, потерян.

Всплытие Да
Отменяемое Да
Интерфейс WebGLContextEvent
Свойство для обработки события Нет

Пример

Вы можете эмулировать webglcontextlost событие с помощью расширения WEBGL_lose_context:

js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");

canvas.addEventListener("webglcontextlost", (event) => {
  console.log(event);
});

gl.getExtension("WEBGL_lose_context").loseContext();

// будет выведено "webglcontextlost".

Спецификации

Specification
WebGL Specification
# 5.15.2

Совместимость с браузерами

Смотрите также