Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Call initThreadPool().
Browse files Browse the repository at this point in the history
Now we have a new error calling Crypto.getRandomValues() backed by a
SharedArrayBuffer.

See: w3c/webcrypto#213
  • Loading branch information
tmpfs committed Dec 3, 2021
1 parent cfd0296 commit 10b9b48
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ Then webassembly needs threads enabled, see:

* https://github.com/GoogleChromeLabs/wasm-bindgen-rayon
* https://rustwasm.github.io/wasm-bindgen/examples/raytrace.html

## Notes

```
TypeError: Crypto.getRandomValues: Argument 1 can't be a SharedArrayBuffer or an ArrayBufferView backed by a SharedArrayBuffer
```
2 changes: 0 additions & 2 deletions client/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//import Worker from "worker-loader!./worker.js";

if (window.Worker) {
// DOM references
const clientLabel = document.querySelector(".client span");
Expand Down
2 changes: 2 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
path: path.resolve(__dirname, "dist"),
filename: "index.js",
},
devtool: false,
mode: "development",
plugins: [new CopyWebpackPlugin(["index.html"])],
devServer: {
Expand All @@ -18,5 +19,6 @@ module.exports = {
experiments: {
//syncWebAssembly: true,
asyncWebAssembly: true,
topLevelAwait: true,
},
};
5 changes: 5 additions & 0 deletions client/worker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import init, { initThreadPool} from 'ecdsa-wasm';

await init();
await initThreadPool(navigator.hardwareConcurrency);

import("ecdsa-wasm")
// Now we have the WASM methods available
.then((wasm) => {
Expand Down

0 comments on commit 10b9b48

Please sign in to comment.