The puppeteer browser instance loads NanoPow with a script and includes CSP. While it specifically uses WebGPU for performance, it was discovered that WASM would not load due to missing required CSP directives, so they have been added.
The reduced WASM iteration count has been reverted since it seems to be an issue with Firefox and not Chromium.
Adjust logging.
const body = `
<!DOCTYPE html>
<link rel="icon" href="data:,">
- <meta http-equiv="Content-Security-Policy" content="default-src 'none'; base-uri 'none'; form-action 'none'; script-src '${enc}';">
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; base-uri 'none'; form-action 'none'; script-src '${enc}' 'wasm-unsafe-eval'; worker-src blob: https://nanopow.invalid;">
<script type="module">${src}</script>
`
let r0: u64 = 0
let r1: u64 = 0
let result = v128.splat<u64>(0)
- const iterations: u64 = 1 << 20
+ const iterations: u64 = 1 << 24
for (let i: u64 = 0; i < iterations; i++) {
m0 = i64x2(unchecked(seed + i), unchecked(seed + i + 1))
return new Promise(resolve => {
const attempts = []
for (let i = 0; i < workers.length; i++) {
- data.seed = bigintToHex((bigintRandom() & ~((1n << 20n) - 1n)), 16)
+ data.seed = bigintToHex((bigintRandom() & ~((1n << 24n) - 1n)), 16)
attempts.push(new Promise((found, err) => {
const w = workers[i]
w.onerror = err
draw(bigintRandom(), drawFbos[2], queries[2])
let drawIndex = 3
do {
- LOG: logger.log(`drawing frame ${drawIndex}`)
draw(bigintRandom(), drawFbos[drawIndex], queries[drawIndex])
drawIndex = (drawIndex + 1) % 4
- LOG: logger.log(`checking frame ${drawIndex}`)
found = await check(queries[drawIndex])
} while (!found && !timeout)
if (found) result = read(drawFbos[drawIndex])
const module = await WebAssembly.compile(wasmBuffer)
const instance = await WebAssembly.instantiate(module)
isWasmSupported = (instance instanceof WebAssembly.Instance)
- } catch (err) {
- console.warn('WASM is not supported in this environment.\n', err)
+ } catch (err: any) {
+ console.warn('WASM is not supported in this environment.\n', err.message ?? err)
isWasmSupported = false
} finally {
delete this.isSupported