rerun-io / rerun

Visualize streams of multimodal data. Fast, easy to use, and simple to integrate. Built in Rust using egui.
https://rerun.io/
Apache License 2.0
5.61k stars 255 forks source link

In Device::create_texture, Dimension Y value 9063 exceeds the limit of 8192 #3337

Closed bchretien closed 8 months ago

bchretien commented 9 months ago

Describe the bug

Hi, first of all thanks for this great tool, it is a pleasure to use!

While trying to load a GLB mesh file with rr.log_mesh_file(mesh_path=...), I get an error in the browser: image

To Reproduce Steps to reproduce the behavior:

  1. Start the web server version of rerun
  2. Call rr.log_mesh_file(mesh_path=...) from Python with a mesh file which contains textures larger than 8192.

Expected behavior

The mesh should be loaded. Other online .gltf/.glb viewers can read the input file successfully:

Screenshots

No relevant screenshot.

Backtrace

[re_renderer::allocator::cpu_write_gpu_read_belt] re_renderer/src/allocator/cpu_write_gpu_read_belt.rs:454: Allocating new CpuWriteGpuReadBelt chunk of size 32.0 MiB 2 re_viewer.js:2198:17
[re_space_view_spatial::mesh_cache] re_space_view_spatial/src/mesh_cache.rs:28: Loading CPU mesh "world/mesh"…        re_viewer.js:2198:17
[re_renderer::importer::gltf] re_renderer/src/importer/gltf.rs:40: Converting Rgb8 to Rgba8                           re_viewer.js:2198:17
ERROR: [wgpu::backend::direct] wgpu-0.16.1/src/backend/direct.rs:3018: Handling wgpu errors as fatal by default       re_viewer.js:2192:17
panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_texture
    Dimension Y value 9063 exceeds the limit of 8192

', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.16.1/src/backend/direct.rs:3019:5

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_475b88b4c50a6bba@http://host:9090/re_viewer.js:796:21
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[2906]:0x772b9e
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[6167]:0x97c1ed
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[8893]:0xa8693d
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[6455]:0x9a8f86
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[4982]:0x9050a7
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[6699]:0x9c309a
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[5396]:0x92b80f
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[773]:0x3663e4
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[3828]:0x84e001
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[679]:0x2e6d1f
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[1388]:0x54a4dd
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[1324]:0x506e94
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[9171]:0xa8d3fe
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[958]:0x422ddd
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[1387]:0x54a3f1
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[783]:0x37378d
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[783]:0x36fefd
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[9257]:0xa96833
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[958]:0x422ddd
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[10053]:0xab1557
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[5117]:0x912cfd
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[843]:0x3b1121
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[5117]:0x912cfd
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[2793]:0x75a9d0
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[5117]:0x912cfd
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[2463]:0x6e7ca8
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[473]:0x2dea7
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[7525]:0xa04565
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[1657]:0x5c078b
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[1169]:0x4afa36
@http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:wasm-function[8371]:0xa53da0
__wbg_adapter_52@http://host:9090/re_viewer.js:242:14
real@http://host:9090/re_viewer.js:209:20
re_viewer.js:790:21
Uncaught RuntimeError: unreachable executed
    __wbg_adapter_52 http://host:9090/re_viewer.js:242
    real http://host:9090/re_viewer.js:209
re_viewer.js line 657 > WebAssembly.instantiate:9945619:1
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:9945619
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:11036989
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:10129286
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:9457831
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:10236058
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:9615375
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:3564516
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:8708097
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:3042591
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:5547229
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:5271188
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:11064318
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:4337117
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:5546993
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:3618701
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:3604221
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:11102259
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:4337117
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:11212119
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:9514237
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:3871009
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:9514237
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:7711184
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:9514237
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:7240872
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:188071
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:10503525
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:6031243
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:4913718
    <anonymous> http://host:9090/re_viewer.js line 657 > WebAssembly.instantiate:10829216
    __wbg_adapter_52 http://host:9090/re_viewer.js:242
    real http://host:9090/re_viewer.js:209

Desktop (please complete the following information):

Rerun version

rerun-cli 0.8.2 [rustc 1.72.0 (5680fa18f 2023-08-23), LLVM 16.0.5] x86_64-unknown-linux-gnu, built 2023-09-14T14:27:17Z

Additional context

I guess that the file respects the glTF specs as every reader I found managed to read it. Another surprising thing: the texture's size is actually 12086 x 16116, but 9063 is reported in the error message. The glTF validator returns:

{
    "uri": "mesh.glb",
    "mimeType": "model/gltf-binary",
    "validatorVersion": "2.0.0-dev.3.8",
    "validatedAt": "2023-09-15T13:36:54.636Z",
    "issues": {
        "numErrors": 0,
        "numWarnings": 0,
        "numInfos": 1,
        "numHints": 0,
        "messages": [
            {
                "code": "IMAGE_NPOT_DIMENSIONS",
                "message": "Image has non-power-of-two dimensions: 12086x16116.",
                "severity": 2,
                "pointer": "/images/0"
            }
        ],
        "truncated": false
    },
    "info": {
        "version": "2.0",
        "generator": "obj2gltf",
        "resources": [
            {
                "pointer": "/buffers/0",
                "mimeType": "application/gltf-buffer",
                "storage": "glb",
                "byteLength": 121744988
            },
            {
                "pointer": "/images/0",
                "mimeType": "image/png",
                "storage": "buffer-view",
                "image": {
                    "width": 12086,
                    "height": 16116,
                    "format": "rgb",
                    "primaries": "srgb",
                    "transfer": "srgb",
                    "bits": 8
                }
            }
        ],
        "animationCount": 0,
        "materialCount": 1,
        "hasMorphTargets": false,
        "hasSkins": false,
        "hasTextures": true,
        "hasDefaultScene": true,
        "drawCallCount": 1,
        "totalVertexCount": 125187,
        "totalTriangleCount": 163782,
        "maxUVs": 1,
        "maxInfluences": 0,
        "maxAttributes": 3
    }
}

Could the fact that the texture has non-power-of-two dimensions be a problem here?

Wumpf commented 9 months ago

thank you so much for the detailed error report!

Could the fact that the texture has non-power-of-two dimensions be a problem here?

It's strange that your much larger texture gets reported as smaller. But size is definitely the problem, non-power-of-two should be handled on the other hand. Sadly, 8192 is the common portable limit for texture sizes and what the WebGPU spec guarantees which is why we stick to that limit so far. However, on desktop 16k & 32k are more common limits nowadays (see https://vulkan.gpuinfo.org/displaydevicelimit.php?name=maxImageDimension2D&platform=windows)

bunch of things to do for us here:

bchretien commented 9 months ago

@Wumpf Thanks for the quick feedback!

I'm seeing this limit reported in the other web viewers, https://sandbox.babylonjs.com even reports the texture size as 8192 x 8192, so maybe they all resize the textures silently for such cases.

Wumpf commented 9 months ago

ohhh interesting! Was already wondering if one can enable larger than 8k in the browser. Thanks for digging that up!! We should then also consider doing texture resizing, just less silent 😄 . First of all ofc is "not crashing" 😳

bchretien commented 9 months ago

Note: this also happens with log_image, so it should be easy to reproduce and test.

emilk commented 8 months ago

The crash has been fixed, and have been replaced with a logged warning and an empty spaceview.

I've created a new issue to track support for larger images in general:

bchretien commented 8 months ago

@emilk perfect, thanks!