@@ -18,7 +18,7 @@ Then in your code
1818import { create , globals } from ' node-webgpu' ;
1919
2020Object .assign (globalThis , globals);
21- globalThis . navigator = { gpu: create ([]) };
21+ const navigator = { gpu: create ([]) };
2222
2323...
2424
@@ -32,7 +32,7 @@ see [example](https://github.com/greggman/node-webgpu/tree/main/example)
3232You can pass dawn options in ` create `
3333
3434``` js
35- globalThis . navigator = {
35+ const navigator = {
3636 gpu: create ([
3737 " enable-dawn-features=allow_unsafe_apis,dump_shaders,disable_symbol_renaming" ,
3838 ]),
@@ -45,8 +45,29 @@ The available options are listed [here](https://dawn.googlesource.com/dawn/+/ref
4545
4646## Notes
4747
48+ ### Lifetime
49+
50+ The ` dawn.node ` implementation exists as long as the ` navigator ` variable
51+ in the examples is in scope, or rather, as long as there is a reference to
52+ the object returned by ` create ` . As such, if you assign it to a global
53+ variable like this
54+
55+ ``` js
56+ globalThis .navigator = { gpu: create ([]) };
57+ ```
58+
59+ node will not exit because it's still running GPU code in the background.
60+ You can fix that by removing the reference.
61+
62+ ``` js
63+ delete globalThis .navigator
64+ ```
65+
66+ See: https://issues.chromium.org/issues/387965810
67+
68+ ### What to use this for
4869This package provides a WebGPU implementation it node. That said, if you are making a webpage
49- and are considering using this for testing, you'd probably be better off using puppeteer. You can
70+ and are considering using this for testing, you'd probably be better off using [ puppeteer] ( https://pptr.dev/ ) . You can
5071find an example of using puppeteer for testing WebGPU in [ this repo] ( https://github.com/greggman/webgpu-debug-helper ) .
5172
5273This package is for WebGPU in node. It provides WebGPU in node. But, it does not not provide integration
@@ -58,9 +79,13 @@ I suspect you could provide many of those with polyfills without changing this r
5879looked into it.
5980
6081What you can do is render to textures and then read them back. You can also run compute shaders
61- and read their results.
82+ and read their results. See the example linked above.
83+
84+ ## Bugs / Issue
6285
63- ## Bugs
86+ This repo just publishes ` dawn.node ` from the dawn project [ here] ( https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/node/ ) .
87+ Bugs related to dawn, WebGPU should be filed in the in the
88+ [ chromium issue tracker] ( https://crbug.com/dawn )
6489
6590## Updating
6691
0 commit comments