bevyengine / bevy

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

[wasm, phone browser] Dimension Y value 5038 exceeds the limit of 4096 #7591

Open smessmer opened 1 year ago

smessmer commented 1 year ago

Bevy version

0.9.1

[Optional] Relevant system information

AdapterInfo { name: "Adreno (TM) 650", vendor: 20803, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }

What you did

Caused by: In Device::create_texture note: label = view_depth_texture Dimension Y value 5038 exceeds the limit of 4096

', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.2/src/backend/direct.rs:2403:5



Not sure what is causing this, I'm not loading any explicit depth texture and none of my regular textures are above 4096 in size. Is this a depth texture that bevy loads somehow? Interestingly, the bevy examples from bevyengine.org do work in the same mobile browser though.
jroddev commented 1 year ago

I did some digging on this back in April, here is what I found https://github.com/rust-windowing/winit/issues/2524#issuecomment-1518987014 I took another look today and was able to fix this on my Pixel device for Vanadium and Brave with Bevy 0.11 by doing a couple of things.

For my use-case I am filling the whole page with my canvas.

.add_plugins(DefaultPlugins.build().set(WindowPlugin {
            primary_window: Some(Window {
                fit_canvas_to_parent: true,
                ..default()
            }),
            ..default()
        }))

This combined with the devicePixelRatio of 2.65 was causing the wgpu texture to be too big. To fix it I add this meta tag to the html head

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

I'm not sure if the winit change was actually required because I hadn't tried the meta tag until today.

side-note: for some reason the body has a margin side by default so in my css I also add

body {
    margin: 0;
}
miketwenty1 commented 8 months ago

@jroddev I'm trying this to no success, is this still working for you using latest tagged bevy? or main branch?

jroddev commented 8 months ago

@miketwenty1 I actually can no longer reproduce the problem with my example projects and my device. Tested with Bevy 10, 11, and 12. I thought maybe it was patched on the device, but Chromium is still reporting window.devicePixelRatio as 2.625.

miketwenty1 commented 8 months ago

I'm on bevy main branch right now. but this was still an issue for me on 10, 11, and 12. the specific device is a pixel 6 pro with a pixel ratio of 3.5.

jroddev commented 8 months ago

I'm not sure, sorry. I tried again and cannot reproduce with or without my line anymore. It could be that the resulting resolution is now supported in wgpu (snuck through in a patch version?) or by my device, but then yours is still over the limit.

Which browser are you using? and is it the stock Android OS that came with the device? From my original testing Chromium based browsers had the issue but Firefox worked (Firefox devicePixelRatio was 1)

Just checking that the meta tag was added to the head and not the body in your index.html file?

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    </head>
    <body>
    </body>
</html>

It's not a great solution, but if you just need to get something running you could shrink the size of the canvas on the page enough that it fits within the texture limit. I did this originally by putting a header and some extra buttons on the page until the render surface was small enough. More details on this linked comment.