Код: Выделить всё
const canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
const glContextAttributes = { alpha: true, antialias: false };
let gl = canvas.getContext('webgl2', glContextAttributes);
if (!gl) {
console.log('WebGL2 not supported, falling back to WebGL1.');
gl = canvas.getContext('webgl', glContextAttributes);
}
if (!gl) {
throw new Error('WebGL not supported in this browser.');
}
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
document.body.appendChild(canvas);
const shader = gl.createShader(gl.VERTEX_SHADER);
if (!shader) {
debugInfo.glError = gl.getError();
debugInfo.contextLost = gl.isContextLost();
throw new Error(`Failed to create ${gl.VERTEX_SHADER} shader. ${JSON.stringify(debugInfo)}`);
}
Не удалось создать шейдер 35633. {"glError":37442,"contextLost":true
Для пользователей, с которыми это происходит, это происходит в 100% случаев. Я понятия не имею, как им помочь.
Как контекст WebGL потерялся так быстро? Я только что создал холст. Не прошло ни одного оборота цикла событий. Могу ли я что-нибудь сделать, чтобы предотвратить это (или хотя бы смягчить последствия)?
Подробнее здесь: https://stackoverflow.com/questions/798 ... ost-on-ios
Мобильная версия