}
}`
- console.log(`shaders start: ${performance.now()}`)
const vertexShader = this.gl.createShader(this.gl.VERTEX_SHADER)
if (vertexShader == null)
throw 'error creating vertex shader'
// Draw output until success or progressCallback says to stop
const work0 = new Uint8Array(4)
const work1 = new Uint8Array(4)
- console.log(`shaders end: ${performance.now()}`)
const draw = (): void => {
if (this.gl == null) throw new Error('webgl2_required')
const start = performance.now()
- console.log(`crypto start: ${performance.now()}`)
crypto.getRandomValues(work0)
crypto.getRandomValues(work1)
- console.log(`crypto end: ${performance.now()}`)
- console.log(`uiv start: ${performance.now()}`)
this.gl.uniform4uiv(work0Location, work0)
this.gl.uniform4uiv(work1Location, work1)
- console.log(`uiv end: ${performance.now()}`)
- console.log(`clear start: ${performance.now()}`)
this.gl.clear(this.gl.COLOR_BUFFER_BIT)
- console.log(`clear end: ${performance.now()}`)
- console.log(`draw start: ${performance.now()}`)
this.gl.drawArrays(this.gl.TRIANGLES, 0, 6)
- console.log(`draw end: ${performance.now()}`)
const pixels = new Uint8Array(this.gl.drawingBufferWidth * this.gl.drawingBufferHeight * 4)
console.log(`start readPixels: ${performance.now()}`)
// Check the pixels for any success
for (let i = pixels.length - 4; i >= 0; i -= 4) {
if (pixels[i] !== 0) {
- console.log(`found: ${performance.now()}`)
console.log(`frame time: ${performance.now() - start}`)
// Return the work value with the custom bits
typeof callback === 'function' &&