Expose context lost simulator
This commit is contained in:
parent
32aebe9036
commit
69ad74ed73
8 changed files with 36 additions and 11 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { formatLog } from '../../../helper/format-log';
|
||||
|
||||
/** @internal */
|
||||
let isEnabled = false;
|
||||
|
||||
|
|
@ -14,12 +16,12 @@ export const enableContextLostSimulator = (canvas: HTMLCanvasElement) => {
|
|||
|
||||
const simulateContextLost = () => {
|
||||
ext.loseContext();
|
||||
console.log('lost');
|
||||
console.info(formatLog('context-lost-simulator', 'lost'));
|
||||
|
||||
const restoreTimeout = Math.random() * 500;
|
||||
setTimeout(() => {
|
||||
ext.restoreContext();
|
||||
console.log('restored');
|
||||
console.info(formatLog('context-lost-simulator', 'restored'));
|
||||
}, restoreTimeout);
|
||||
|
||||
setTimeout(() => simulateContextLost(), restoreTimeout + Math.random() * 500);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { formatLog } from '../../helper/format-log';
|
||||
import { numberToGlslFloat } from '../../helper/number-to-glsl-float';
|
||||
import { wait } from '../../helper/wait';
|
||||
import { tryEnableExtension } from './helper/enable-extension';
|
||||
|
|
@ -138,9 +139,12 @@ export class ParallelCompiler {
|
|||
const line = Number.parseInt(match[1]);
|
||||
const error = match[2];
|
||||
console.error(
|
||||
`Error: ${error}\nSource (line ${line}):\n${
|
||||
shader.source.split('\n')[line - 1]
|
||||
}`
|
||||
formatLog(
|
||||
'parallel-compiler',
|
||||
`Error: ${error}\nSource (line ${line}):\n${
|
||||
shader.source.split('\n')[line - 1]
|
||||
}`
|
||||
)
|
||||
);
|
||||
}
|
||||
throw new Error('Error while compiling shader');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue