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

Issue with emscripten version #3

Open
sthitadhisengupta opened this issue Aug 28, 2024 · 14 comments
Open

Issue with emscripten version #3

sthitadhisengupta opened this issue Aug 28, 2024 · 14 comments

Comments

@sthitadhisengupta
Copy link

Which emscripten version did you use to compile this code? I tried the 3.1.45 version and it didn't work for me.

@seyhajin
Copy link
Owner

seyhajin commented Aug 28, 2024

@sthitadhisengupta

I had updated the code for version 3.1.51+ with the following changes (8917c79).
If you have an earlier version, you will probably need to not apply these changes.

EDIT: I have updated the code to work with the latest version of Emscripten (3.1.65).

@sthitadhisengupta
Copy link
Author

I see. So I tried compiling your code with the latest version of emscripten. While it compiled, I had the following issue when running on the Chrome browser:

githuberror

Any ideas why this is happening?

@seyhajin
Copy link
Owner

seyhajin commented Aug 30, 2024

Can you show me the contents of “Aborted (Assertion failed)”?
What web server do you use?
Are you sure your web browser supports WebGPU?

@ColleagueRiley
Copy link

ColleagueRiley commented Oct 20, 2024

I'm getting a similar issue on IOS although the samples on https://webgpu.github.io/webgpu-samples/ work fine. I don't know if this is an issue with my device or Emscripten, that site is using typescript.

@seyhajin
Copy link
Owner

seyhajin commented Oct 20, 2024

Strange. Are you using the shell.html file provided during compilation?
With Emscripten, the emscripten_webgpu_get_device function used in C must first retrieve the WebGPU device from the web page to define Module.preinitalizeWebGPUDevice property.
See the following lines (L63):

webgpu-wasm-c/shell.html

Lines 28 to 68 in 77ca780

initWebGPU = async () => {
// Check to ensure the user agent supports WebGPU
if (!('gpu' in navigator)) {
const msg = '⚠️ WebGPU is not available on this browser.';
const pre = document.createElement('pre');
pre.style.color = '#f00';
pre.style.textAlign = 'center';
pre.textContent = msg;
document.body.appendChild(pre);
console.error(msg);
return false;
}
// Request an adapter
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
console.error('No WebGPU adapters found.');
return false;
}
// Request a device
const device = await adapter.requestDevice();
device.lost.then((info) => {
console.error(`WebGPU device was lost: ${info.message}`);
device = null;
if (info.reason != 'destroyed') {
initWebGPU();
}
});
// Set WebGPU device in Module
Module.preinitializedWebGPUDevice = device;
return true;
}
initWebGPU();

The default Emscripten shell does not provide this property and that would explain your error message. Otherwise, share your output files.

@ColleagueRiley
Copy link

Strange. Are you using the shell.html file provided during compilation? With Emscripten, the emscripten_webgpu_get_device function used in C must first retrieve the WebGPU device from the web page to define Module.preinitalizeWebGPUDevice property. See the following lines (L63):

webgpu-wasm-c/shell.html

Lines 28 to 68 in 77ca780

initWebGPU = async () => {
// Check to ensure the user agent supports WebGPU
if (!('gpu' in navigator)) {
const msg = '⚠️ WebGPU is not available on this browser.';
const pre = document.createElement('pre');
pre.style.color = '#f00';
pre.style.textAlign = 'center';
pre.textContent = msg;
document.body.appendChild(pre);
console.error(msg);
return false;
}
// Request an adapter
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
console.error('No WebGPU adapters found.');
return false;
}
// Request a device
const device = await adapter.requestDevice();
device.lost.then((info) => {
console.error(`WebGPU device was lost: ${info.message}`);
device = null;
if (info.reason != 'destroyed') {
initWebGPU();
}
});
// Set WebGPU device in Module
Module.preinitializedWebGPUDevice = device;
return true;
}
initWebGPU();

The default Emscripten shell does not provide this property and that would explain your error message. Otherwise, share your output files.

My code merges the shell.html and the final .HTML file. But I'm mostly going based on the itch.io link you have.

@seyhajin
Copy link
Owner

My code merges the shell.html and the final .HTML file. But I'm mostly going based on the itch.io link you have.

I have updated the zip file on the itch.io link. Could you try again?

@ColleagueRiley
Copy link

It’s just a black screen for me.

@seyhajin
Copy link
Owner

It’s just a black screen for me.

Which web browser are you using and does it support WebGPU?
Are there any errors in the JavaScript console (Dev Tools)?

@ColleagueRiley
Copy link

The other site works fine, so it should work it. As for the dev log. I’m running it on iOS and I’m not sure how to open the dev log if I can.

@seyhajin
Copy link
Owner

I have try on iOS Safari and that works for me (iOS 18).
You need to activate "WebGPU" flag in Safari settings and restart Safari.

@ColleagueRiley
Copy link

I have try on iOS Safari and that works for me (iOS 18).

You need to activate
"WebGPU" flag in Safari settings and restart Safari.

I did have it enabled but I was using IOS 17. I updated to IOS 18 and made sure it was enabled, but the same issue happened. If it was not enabled the other site would not work.

@ColleagueRiley
Copy link

I’m testing with the itch.io link, but I’m trying to see if this works because I’m using a modified version of your code for my project. https://colleagueriley.github.io/RGFW/webasm/webgpu.html

@ColleagueRiley
Copy link

After resetting Safari twice, it started working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants