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

wgpu Validation Error on startup #298

Closed
SolarLiner opened this issue Apr 14, 2024 · 26 comments
Closed

wgpu Validation Error on startup #298

SolarLiner opened this issue Apr 14, 2024 · 26 comments
Labels
bug Something isn't working

Comments

@SolarLiner
Copy link

Describe the bug
The editor somehow causes Bevy to create an invalid viewport rect, that is outside the render target.

To Reproduce
From a blank Bevy project, add the space editor as shown on the README, and add the SpaceEditorPlugin, as well as the simple_editor_setup startup system.

Expected behavior
Editor opens without causing a wgpu failure.

Screenshots
wgpu shows the following failure message (shown here with the DX12 backend, but is also reproducible on the Vulkan backend)

wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(0, 1, Dx12)>`
    In a set_viewport command
    Viewport has invalid rect Rect { x: 2001.0, y: 74.0, w: 7999.0, h: 9896.0 }; origin and/or size is less than or equal to 0, and/or is not contained in the render target (1600, 900, 1)

Desktop (please complete the following information):

  • OS: Windows 11
  • Project Version 0.5 (assuming "project version" here means the version of space editor), rev 5067ab5
  • Rust Verion: 1.77.2

Additional context
Removing the simple_editor_setup removes the validation error, but leaves the "Game View" tab empty.

This bug seems to be Windows-specific, as I cannot reproduce on macOS.

As is often the case with these kinds of bugs, I have a display scale factor of 125% in my system settings, though the viewport values don't seem to nicely tie to the display value by that display scale factor, so I don't know how relevant this is.

@SolarLiner SolarLiner added the bug Something isn't working label Apr 14, 2024
@naomijub
Copy link
Collaborator

naomijub commented Apr 15, 2024

I've seen that error before, will try to take a look this week.
Do you have an open source repo that I could use to test?

@rewin123
Copy link
Owner

I have encountered this bug and for me it disappeared after updating space_editor to 0.13.2. (That is, the bug was tied specifically to 0.13.1). Can you please try this PR #299 ?

@SolarLiner
Copy link
Author

That unfortunately does not solve the issue, I get the same wgpu validation error.

@naomijub
Copy link
Collaborator

Is your windows Up to date?

@SolarLiner
Copy link
Author

I believe it is, I had a system update a few days ago and haven't had any GPU driver update notifications popping up, but I'll check for updates tomorrow and see if anything needs to be done.

@SolarLiner
Copy link
Author

I have everything up to date, except for my GPU drivers, which I updated before trying again, to no avail, it still fails with the same error.

Here's the full log:

2024-04-16T18:07:59.230457Z  INFO bevy_winit::system: Creating new window "App" (0v1)
2024-04-16T18:08:00.193404Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3060", vendor: 4318, device: 9476, device_type: DiscreteGpu, driver: "", driver_info: "", backend: Dx12 }
2024-04-16T18:08:00.624858Z ERROR space_editor_ui::meshless_visualizer: Failed to dynamic load assets. Loading defaults from memory
2024-04-16T18:08:00.635044Z  INFO space_bevy_xpbd_plugin: Add bevy_xpbd_3d plugin to editor
BevyXpbdPlugin::build
2024-04-16T18:08:00.706894Z  INFO space_editor_ui: Set start state
2024-04-16T18:08:00.818532Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Home", kernel: "22631", cpu: "13th Gen Intel(R) Core(TM) i5-13600K", core_count: "14", memory: "31.8 GiB" }
2024-04-16T18:08:00.892620Z  INFO bevy_input::gamepad: Gamepad { id: 0 } Connected
2024-04-16T18:08:01.458089Z ERROR log: Handling wgpu errors as fatal by default    
thread '<unnamed>' panicked at C:\Users\solarliner\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.3\src\backend\wgpu_core.rs:3006:5:
wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(0, 1, Dx12)>`
    In a set_viewport command
    Viewport has invalid rect Rect { x: 2001.0, y: 74.0, w: 7999.0, h: 9896.0 }; origin and/or size is less than or equal to 0, and/or is not contained in the render target (1600, 900, 1)

@naomijub
Copy link
Collaborator

Can you try using the branch v0.6? I think my fix for this issue was merged in that branch and I don't recall what it was

@naomijub
Copy link
Collaborator

naomijub commented Apr 17, 2024

So running cargo run --example space_example and cargo run --example space_example --release on main seems to work well on my MacOS and my Windows 🤔, I'm really curious what can it be.

Do you have space_editor as a plugin and you project bevy has no-default-features?

@SolarLiner
Copy link
Author

SolarLiner commented Apr 17, 2024

The examples in main don't have the issue, so that's great, however the v0.6 branch still fails for me.

My repro crate literally has this:

Cargo.toml
bevy = "0.13.2"
space_editor = { git = "https://github.com/rewin123/space_editor.git", branch = "v0.6" } # without branch v0.6 initially, added to try the branch out as mentioned above
src/main.rs
use bevy::prelude::*;
use space_editor::prelude::*;

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            SpaceEditorPlugin,
            ))
        .add_systems(Startup, simple_editor_setup)
        .run();
}

@SolarLiner
Copy link
Author

edit, it seems that it only fails when I'm using the editor as a plugin in a separate project -- under the same commit, running the examples work, but running as a plugin in a separate empty project fails. I've tried matching the bevy versions (was using 0.13.2 before, and moved it to 0.13.1) to no avail.

@naomijub
Copy link
Collaborator

That is odd. We have a test for that, but it is using Linux as windows takes longer to compile. Will try to fix it

@naomijub naomijub mentioned this issue Apr 18, 2024
@naomijub
Copy link
Collaborator

@naomijub
Copy link
Collaborator

Added a windows example to the CI, let's see if I can reproduce the error

@naomijub
Copy link
Collaborator

naomijub commented Apr 18, 2024

seems to be working fine on the new CI example https://github.com/rewin123/space_editor/actions/runs/8742952685/job/23992381723:

screenshot-100

@SolarLiner
Copy link
Author

That job seems to be running an example, which also runs fine on my Windows machine. It's when I use it in a separate project, added as a dependency, that it fails.

This is making me think that there is probably some conflict in the dependency resolution by cargo then.

@naomijub
Copy link
Collaborator

The project is consuming bevy and space editor as external dependencies in the test. However, it is a member of the workspace for enabling rust analyzer. I tried using it as an external dependency in another project in my windows machine and was not able to reproduce it.

I won't have my windows machine for the next month, so this is my limit helping with this issue. @rewin123

@LgnMs
Copy link

LgnMs commented Apr 23, 2024

When I use the RigidBody from the bevy_rapier3d library, I encounter an error. @SolarLiner @naomijub

commands
        .spawn((
            RigidBody::KinematicPositionBased,
            SceneBundle {
                scene: asset_server.load("Player.gltf#Scene0"),
                transform: Transform::from_xyz(0.0, 0.5, 0.0),
                ..default()
            },
            Speed(5.0),
            Player,
            Name::new("player"),
        ))

@rewin123
Copy link
Owner

The project is consuming bevy and space editor as external dependencies in the test. However, it is a member of the workspace for enabling rust analyzer. I tried using it as an external dependency in another project in my windows machine and was not able to reproduce it.

I won't have my windows machine for the next month, so this is my limit helping with this issue. @rewin123

Sorry for late reply. Will try reptoduce bug today

@rewin123
Copy link
Owner

When I use the RigidBody from the bevy_rapier3d library, I encounter an error. @SolarLiner @naomijub

commands
        .spawn((
            RigidBody::KinematicPositionBased,
            SceneBundle {
                scene: asset_server.load("Player.gltf#Scene0"),
                transform: Transform::from_xyz(0.0, 0.5, 0.0),
                ..default()
            },
            Speed(5.0),
            Player,
            Name::new("player"),
        ))

I'll try to watch it today too. Do you have the same error as the author of the issue?

@rewin123
Copy link
Owner

rewin123 commented Apr 23, 2024

The project is consuming bevy and space editor as external dependencies in the test. However, it is a member of the workspace for enabling rust analyzer. I tried using it as an external dependency in another project in my windows machine and was not able to reproduce it.
I won't have my windows machine for the next month, so this is my limit helping with this issue. @rewin123

Sorry for late reply. Will try reptoduce bug today

Was able to reproduce it. Indeed, at 100% screen resolution everything works, but at 125% it crashes on my Windows 10 if I run spae_ediotor as a dependency. Starting to fix it. But it works if I run space_editor in crate, weird.....

@LgnMs
Copy link

LgnMs commented Apr 24, 2024

When I use the RigidBody from the bevy_rapier3d library, I encounter an error. @SolarLiner @naomijub

commands
        .spawn((
            RigidBody::KinematicPositionBased,
            SceneBundle {
                scene: asset_server.load("Player.gltf#Scene0"),
                transform: Transform::from_xyz(0.0, 0.5, 0.0),
                ..default()
            },
            Speed(5.0),
            Player,
            Name::new("player"),
        ))

I'll try to watch it today too. Do you have the same error as the author of the issue?

When I ran the example, everything was fine, but when I added it to my personal demo, this error occurred.

@naomijub
Copy link
Collaborator

Hey guys, sorry I haven't been responding. I am in process of moving to another state and haven't had time to touch the project. Mid may I should be able to get back and help more

@rewin123
Copy link
Owner

rewin123 commented May 4, 2024

I really apologize for the late fix. #304 fixed a bug on windows machine on my machine with 125% screen size. (Unfortunately for another two weeks I will be weakly active, as I need to conquer my PhD thesis problems if I want to defend it this year. But if there's any news on this bug, I'll get in touch and will try to add more fixes if the current one doesn't work.)

@naomijub
Copy link
Collaborator

@SolarLiner the bug should have been fixed in main

@SolarLiner
Copy link
Author

I can confirm it works now on the main branch!

@rewin123
Copy link
Owner

rewin123 commented May 13, 2024

Yay. Thanks for the cooperation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants