Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workers can log to the console just fine. #311

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/sample/worker/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ const init: SampleInit = async ({ canvas, pageState }) => {
// complexity. Here we establish a convention that all messages to and from the worker will
// have a `type` field that we can use to determine the content of the message.
switch (ev.data.type) {
case 'log': {
// Workers don't have a built-in mechanism for logging to the console, so it's useful to
// create a way to echo console messages.
console.log(ev.data.message);
break;
}
default: {
console.error(`Unknown Message Type: ${ev.data.type}`);
}
Expand Down
7 changes: 3 additions & 4 deletions src/sample/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ self.addEventListener('message', (ev) => {
try {
init(ev.data.offscreenCanvas);
} catch (err) {
self.postMessage({
type: 'log',
message: `Error while initializing WebGPU in worker process: ${err.message}`,
});
console.error(
`Error while initializing WebGPU in worker process: ${err.message}`
);
}
break;
}
Expand Down
Loading