bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.02k stars 3.43k forks source link

Can not load 3D examples on the website #14415

Open rijenkii opened 1 month ago

rijenkii commented 1 month ago

Bevy version

N/A

[Optional] Relevant system information

What you did

Opened https://bevyengine.org/examples/3d-rendering/3d-scene/.

What went wrong

Example did not load, logs contained exceptions.

Additional information

ERROR   Shader compilation failed: ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit
 log.target = "wgpu_hal::gles::device";
log.module_path = "wgpu_hal::gles::device";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/device.rs";
log.line = 200;

ERROR  Device::create_render_pipeline error: Internal error in ShaderStages(VERTEX) shader: ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit
 log.target = "wgpu_core::device::global";
log.module_path = "wgpu_core::device::global";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.21.1/src/device/global.rs";
log.line = 1636;

ERROR  Shader translation error for stage ShaderStages(VERTEX): ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit
 log.target = "wgpu::backend::wgpu_core";
log.module_path = "wgpu::backend::wgpu_core";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs";
log.line = 1179;

ERROR  Please report it to https://github.com/gfx-rs/wgpu log.target = "wgpu::backend::wgpu_core";
log.module_path = "wgpu::backend::wgpu_core";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs";
log.line = 1180;

ERROR  Handling wgpu errors as fatal by default log.target = "wgpu::backend::wgpu_core";
log.module_path = "wgpu::backend::wgpu_core";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs";
log.line = 2995;
panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:2996:5:
wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `pbr_opaque_mesh_pipeline`
    Internal error in ShaderStages(VERTEX) shader: ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:1842:21
@:wasm-function[53516]:0x125e54d
@:wasm-function[15577]:0xfab7a8
@:wasm-function[28781]:0x11ae7c3
@:wasm-function[15439]:0xfa4a52
@:wasm-function[24116]:0x10c86a2
@:wasm-function[572]:0x1f4d74
@:wasm-function[977]:0x445405
@:wasm-function[4414]:0x98adf0
@:wasm-function[52819]:0x125a0af
@:wasm-function[2034]:0x6fb6a2
@:wasm-function[14738]:0xf34417
@:wasm-function[4632]:0x9c4abc
@:wasm-function[10779]:0xdba479
@:wasm-function[6834]:0xbcc490
@:wasm-function[3038]:0x801311
@:wasm-function[5017]:0xa1d021
@:wasm-function[32188]:0x11dd6c5
@:wasm-function[31975]:0x11db69b
__wbg_adapter_45@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:229:10
real@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:210:20
FrameRequestCallback*__wbg_get_imports/imports.wbg.__wbg_requestAnimationFrame_549258cfa66011f0/<@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:1012:37
handleError@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:246:18
__wbg_get_imports/imports.wbg.__wbg_requestAnimationFrame_549258cfa66011f0@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:1011:84
@:wasm-function[15248]:0xf86a97
@:wasm-function[6834]:0xbccbcf
@:wasm-function[3038]:0x801311
@:wasm-function[30330]:0x11c7828
@:wasm-function[1004]:0x478334
@:wasm-function[51897]:0x124e86c
@:wasm-function[29483]:0x11b400e
@:wasm-function[51894]:0x124e841
__wbg_finalize_init@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:2159:10
__wbg_init@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:2195:12
async*@https://bevyengine.org/examples/3d-rendering/3d-scene/:420:3
Uncaught RuntimeError: unreachable executed
    __wbg_adapter_45 https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:229
    real https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:210
    __wbg_requestAnimationFrame_549258cfa66011f0 https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:1012
    handleError https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:246
    __wbg_requestAnimationFrame_549258cfa66011f0 https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:1011
    __wbg_finalize_init https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:2159
    __wbg_init https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:2195
    async* https://bevyengine.org/examples/3d-rendering/3d-scene/:420

Tried opening demos on wgpu.rs, all of the WebGL 2 seemed to run with no errors thrown.

JMS55 commented 1 month ago

That's a really old iGPU from ~2008. It's too old to support Bevy's builtin StandardMaterial.

rijenkii commented 1 month ago

That's an integrated GPU in the AMD 5600G CPU from 2021:

> glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: AMD (0x1002)
    Device: AMD Radeon Graphics (radeonsi, renoir, LLVM 18.1.6, DRM 3.57, 6.9.9-200.fc40.x86_64) (0x1638)
    Version: 24.1.2
    Accelerated: yes
    Video memory: 512MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 69 MB, largest block: 69 MB
    VBO free aux. memory - total: 14789 MB, largest block: 14789 MB
    Texture free memory - total: 69 MB, largest block: 69 MB
    Texture free aux. memory - total: 14789 MB, largest block: 14789 MB
    Renderbuffer free memory - total: 69 MB, largest block: 69 MB
    Renderbuffer free aux. memory - total: 14789 MB, largest block: 14789 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 512 MB
    Total available memory: 16239 MB
    Currently available dedicated video memory: 69 MB
OpenGL vendor string: AMD
OpenGL renderer string: AMD Radeon Graphics (radeonsi, renoir, LLVM 18.1.6, DRM 3.57, 6.9.9-200.fc40.x86_64)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 24.1.2
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6 (Compatibility Profile) Mesa 24.1.2
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.1.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
JMS55 commented 1 month ago

Oh weird, the adapter name is very misleading then.

rijenkii commented 1 month ago

Tried opening the example with chromium browser, it opened fine. Console reported following adapter: AdapterInfo { name: "ANGLE (AMD, AMD Radeon Graphics (radeonsi renoir LLVM 18.1.6), OpenGL 4.6)", vendor: 4098, device: 0, device_type: Other, driver: "WebGL 2.0 (OpenGL ES", driver_info: "3.0 Chromium)", backend: Gl }

rijenkii commented 1 month ago

Oh weird, the adapter name is very misleading then.

Probably related to the fact that WEBGL_debug_renderer_info is deprecated in Firefox and is equivalent to gl.getParameter(gl.RENDERER) and gl.getParameter(gl.VERSION).

StudioLE commented 1 month ago

I'm seeing the same issue on a similar operating system:

When opening any web example it shows my adapter as:

INFO crates/bevy_render/src/renderer/mod.rs:189 AdapterInfo { name: "Radeon R9 200 Series, or similar", vendor: 4098, device: 0, device_type: Other, driver: "WebGL", driver_info: "2.0", backend: Gl } wasm_example.js:435:21

However when I run bevy locally it correctly identifies:

AdapterInfo { name: "AMD Radeon RX 6700 XT (RADV NAVI22)", vendor: 4098, device: 29663, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 24.1.4", backend: Vulkan }

Full logs:

An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page. restart-audio-context.js:24:28
An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page. wasm_example.js:1713:37
INFO crates/bevy_winit/src/system.rs:58 Creating new window "App" (Entity { index: 0, generation: 1 }) wasm_example.js:435:21
WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER. wasm_example.js:879:37
INFO crates/bevy_render/src/renderer/mod.rs:189 AdapterInfo { name: "Radeon R9 200 Series, or similar", vendor: 4098, device: 0, device_type: Other, driver: "WebGL", driver_info: "2.0", backend: Gl } wasm_example.js:435:21
WARN crates/bevy_pbr/src/ssao/mod.rs:86 ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING. wasm_example.js:435:21
INFO crates/bevy_core_pipeline/src/dof/mod.rs:799 Disabling depth of field on this platform because depth textures aren't supported correctly wasm_example.js:435:21
ERROR   Shader compilation failed: ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit
 log.target = "wgpu_hal::gles::device";
log.module_path = "wgpu_hal::gles::device";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.21.1/src/gles/device.rs";
log.line = 200; wasm_example.js:435:21
ERROR  Device::create_render_pipeline error: Internal error in ShaderStages(VERTEX) shader: ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit
 log.target = "wgpu_core::device::global";
log.module_path = "wgpu_core::device::global";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.21.1/src/device/global.rs";
log.line = 1636; wasm_example.js:435:21
ERROR  Shader translation error for stage ShaderStages(VERTEX): ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit
 log.target = "wgpu::backend::wgpu_core";
log.module_path = "wgpu::backend::wgpu_core";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs";
log.line = 1179; wasm_example.js:435:21
ERROR  Please report it to https://github.com/gfx-rs/wgpu log.target = "wgpu::backend::wgpu_core";
log.module_path = "wgpu::backend::wgpu_core";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs";
log.line = 1180; wasm_example.js:435:21
ERROR  Handling wgpu errors as fatal by default log.target = "wgpu::backend::wgpu_core";
log.module_path = "wgpu::backend::wgpu_core";
log.file = "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs";
log.line = 2995; wasm_example.js:435:21
panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:2996:5:
wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `pbr_opaque_mesh_pipeline`
    Internal error in ShaderStages(VERTEX) shader: ERROR: 0:? : '' : Total size of declared private variables exceeds implementation-defined limit

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:1842:21
@:wasm-function[53516]:0x125e54d
@:wasm-function[15577]:0xfab7a8
@:wasm-function[28781]:0x11ae7c3
@:wasm-function[15439]:0xfa4a52
@:wasm-function[24116]:0x10c86a2
@:wasm-function[572]:0x1f4d74
@:wasm-function[977]:0x445405
@:wasm-function[4414]:0x98adf0
@:wasm-function[52819]:0x125a0af
@:wasm-function[2034]:0x6fb6a2
@:wasm-function[14738]:0xf34417
@:wasm-function[4632]:0x9c4abc
@:wasm-function[10779]:0xdba479
@:wasm-function[6834]:0xbcc490
@:wasm-function[3038]:0x801311
@:wasm-function[5017]:0xa1d021
@:wasm-function[32188]:0x11dd6c5
@:wasm-function[31975]:0x11db69b
__wbg_adapter_45@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:229:10
real@https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:210:20

wasm_example.js:1858:21
    __wbg_error_f851667af71bcfc6 https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:1858
    <anonymous> source20:19260964
    <anonymous> source20:16431016
    <anonymous> source20:18540483
    <anonymous> source20:16403026
    <anonymous> source20:17598114
    <anonymous> source20:2051444
    <anonymous> source20:4477957
    <anonymous> source20:10006000
    <anonymous> source20:19243183
    <anonymous> source20:7321250
    <anonymous> source20:15942679
    <anonymous> source20:10242748
    <anonymous> source20:14394489
    <anonymous> source20:12371088
    <anonymous> source20:8393489
    <anonymous> source20:10604577
    <anonymous> source20:18732741
    <anonymous> source20:18724507
    __wbg_adapter_45 https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:229
    real https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:210
Uncaught RuntimeError: unreachable executed
    __wbg_adapter_45 https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:229
    real https://bevy-webgl2-examples.pages.dev/3D Rendering/3d-scene/wasm_example.js:210

An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page. 2 wasm_example.js:1686:25
Mat-Stevenson-Simworx commented 1 month ago

I am seeing the same error on my own project. Seems to work fine on any Chromium based browsers and standalone.

Also working on some other machines with Firefox:

janhohenheim commented 1 month ago

Tagging as O-Linux since this only happened on Linux machines so far. Also note this is also only happening on Firefox so far.

benfrankel commented 1 month ago

I see this error on https://janhohenheim.itch.io/bike-game.

RobertoMaurizzi commented 1 month ago

I do NOT see the problem with https://janhohenheim.itch.io/bike-game

I just realized that even if I start both browsers under primusrun they still uses the Intel GPU for some reason, so no testing under Nvidia unless I find a way to fix this :sweat_smile:

Again "Crazy Bike" works in both browser quite smoothly... :thinking:

UPDATE

I tried Firefox 128 (from Flatpak installation) and it tried to compile shaders and got the same exact error as StudioLE! The console still reports "AdapterInfo { name: "Intel(R) HD Graphics, or similar", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "WebGL", driver_info: "2.0", backend: Gl }" so I'd dare say something broke between 115 and 128 for Firefox...

janhohenheim commented 1 month ago

Note for maintainers: Crazy Bike does not use any customs shaders, any crashing shader code is coming from Bevy.

TrialDragon commented 1 month ago

I do not have this error on https://janhohenheim.itch.io/bike-game.

OS: Fedora Linux 40 (Workstation Edition) WM: GNOME 46 X11 Browser: Firefox v128.0 Reported Browser GPU: AdapterInfo { name: "NVIDIA GeForce GTX 980, or similar", vendor: 4318, device: 0, device_type: Other, driver: "WebGL", driver_info: "2.0", backend: Gl } Native GPU: AdapterInfo { name: "NVIDIA GeForce 2060", vendor: 4318, device: 7817, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.58.02", backend: Vulkan }

GitGhillie commented 1 month ago

Same issue here with both the bike game and the bevy example:

With Chromium they work great and the adapter info is as following: AdapterInfo { name: "ANGLE (AMD, GFX1100 (gfx1100 LLVM 15.0.7 DRM 3.57 6.8.0-39-generic), OpenGL 4.6)", vendor: 4098, device: 0, device_type: Other, driver: "WebGL 2.0 (OpenGL ES", driver_info: "3.0 Chromium)", backend: Gl } (My GPU is a RX 7900XT)

mockersf commented 1 month ago

From RobertoMaurizzi comment it seems to be something broken in Firefox

Could someone for whom it's not working with Firefox 128 test with an older version and confirm that? Then report upstream to Firefox...

RobertoMaurizzi commented 1 month ago

It looks like recent versions of Firefox are exploding if they can't use a real GPU. Later today I'll try to see if I can convince my Firefox 128 from Flatpak to run under primusrun so it can access the Nvidia GPU.

Elabajaba commented 1 month ago

From RobertoMaurizzi comment it seems to be something broken in Firefox

Could someone for whom it's not working with Firefox 128 test with an older version and confirm that? Then report upstream to Firefox...

I asked on the wgpu matrix, and firefox already has a private bug report for it. It's also broken on firefox nightly and beta on Linux+RADV (amd mesa driver).

Firefox 127 works.

janhohenheim commented 1 month ago

Marking as blocked since this should be fixed by Firefox imo

samlh commented 1 month ago

I asked on the wgpu matrix, and firefox already has a private bug report for it. It's also broken on firefox nightly and beta on Linux+RADV (amd mesa driver).

Hm, from my reading of the chat conversation, there was a recent security bug that changed the logic for emitting this error in Firefox.

Note: I don't think anyone has filed a bug for the recent change breaking Bevy - I'd recommend opening one.

alexpyattaev commented 1 month ago

Whatever is going on is still going on. Firefox is still 100% broken. Mozilla Firefox 129.0b6 reports the same error. A few questions:

alexpyattaev commented 1 month ago

Well I've made one just because I can=) https://github.com/webcompat/web-bugs/issues/139923

janhohenheim commented 1 month ago

@alexpyattaev thanks!

mockersf commented 1 month ago

my CI just got updated to Firefox 128 and can now reproduce this error so... yay 🎉

Elabajaba commented 1 month ago

my CI just got updated to Firefox 128 and can now reproduce this error so... yay 🎉

What GPU is the CI running on? I'm pretty sure this is a Mesa specific issue, and not just limited to AMD.

mockersf commented 1 month ago

my CI just got updated to Firefox 128 and can now reproduce this error so... yay 🎉

What GPU is the CI running on? I'm pretty sure this is a Mesa specific issue, and not just limited to AMD.

No GPU, it's software rendering with llvmpipe

mockersf commented 1 month ago

the last few commits on https://github.com/mozilla/angle/commits/main/ seem related, but no idea which version of angle firefox 127/128 are using

alexpyattaev commented 4 weeks ago

Up to date mozilla bug is now here https://bugzilla.mozilla.org/show_bug.cgi?id=1912404

njaard commented 2 weeks ago

I also see this on a Radeon RX 460 (2016):

Why is it that my GPU is a RX 460, but bevy reports an R9 200?

Elabajaba commented 2 weeks ago

Why is it that my GPU is a RX 460, but bevy reports an R9 200?

Firefox buckets all GPUs into a few different device names for privacy reasons (at the expense of webgl programmers sanity).

Edit: Interesting. I've only seen this bug reported on Firefox 128+ so far (there's even a Debian user above that didn't have it on FF 115 ESR), but maybe they backported the change that broke bevy webgl2 in an ESR update.

alexpyattaev commented 2 weeks ago

I have FF130 already, and there is literally no progress on their end. I do not think FF will ever fix this to be honest.

zand commented 2 weeks ago

After going to about:config and changing the setting for webgl.glsl.max_private_var_size_in_bytes from -1 to 65536 (64KB), the background for the animated-fox example rendered with errors. Setting it to 131072 (128KB) allowed the example to run without errors.

Changing about:config is not a fix for the underlining issue where the default setting is too low, or its interpretation of it is incorrect.

It looks like in response to CVE-2024-6600, commit 7a72f1c5 was added to limit Mesa to 16384 (16KB) and MacOs to 131072 (128KB).

mockersf commented 1 week ago

Should Bevy need to allocate that much for a simple 3d example?

alexpyattaev commented 1 week ago

Even if the simple example could fit into 16 KB, any reasonable bevy game would likely consume far more than 16 KB. It is massively stupid for the browser to impose such limits. I get imposing a limit of e.g. 256 MB for the entire tab or something like that, and asking a user if tab wants more RAM, but the current behavior is just dumb. The user assumes the app is broken, and the app dev has no recourse other than asking user to change settings for all tabs (which has security implications).