bevyengine / bevy

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

wgpu crashes on Redmi k60pro mobile phone due to too high of resolution #16361

Open ysypnbh opened 4 days ago

ysypnbh commented 4 days ago

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

This is my actual machine demonstration. Please tell me how to solve it. I also want to write a demo that can be displayed on mobile phones.

wasm_example.js:1885 panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.20.1/src/backend/wgpu_core.rs:751:18:
Error in Surface::configure: Validation Error

Caused by:
    `Surface` width and height must be within the maximum supported texture size. Requested was (4480, 2520), maximum extent for either dimension is 4096.

Stack:

Error
    at imports.wbg.__wbg_new_abda76e883ba8a5f (https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example.js:1869:21)
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[53132]:0x125c108
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[15774]:0xfa878b
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[26849]:0x1177b99
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[22765]:0x109e733
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[9796]:0xd5761c
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[3380]:0x83cab6
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[51476]:0x124c632
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[2077]:0x6eced3
    at https://bevy-webgl2-examples.pages.dev/3D%20Rendering/3d-scene/wasm_example_bg.wasm:wasm-function[14528]:0xf1ac5d

Image

If you look at it from the browser's debugging page, it's normal, but I don't know why the progress bar doesn't disappear.

Image

It's the same with 2D

Image

mockersf commented 4 days ago

The fact that it crashes is because of the scale factor of your phone. It has a high dpi, and Bevy use that to multiply the texture size which gives in your case something bigger than what your phone GPU supports.

This is a long standing Bevy bug that I thought was fixed, and will changed from phone to phone.

By default, Bevy tries to display in a 1280x720 canvas, which on your phone means a 4480x2520, so you have a 3.5 scale factor. As the maximum texture size is 4096, you can try to change the window size in Bevy on init to be at most 1170 pixel width.

BenjaminBrienen commented 3 days ago

Should the solution be to use the maximum size texture and scale it, or to use two textures, or something else?