Trouv / bevy_ecs_ldtk

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
Other
702 stars 81 forks source link

Panic at starting minimal project #67

Closed igordreher closed 2 years ago

igordreher commented 2 years ago

Thread main panics when running a minimal setup code.

bevy_ecs_ldtk panic

Code used:

use bevy::prelude::*;
use bevy_ecs_ldtk as ldtk;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(ldtk::LdtkPlugin)
        .add_startup_system(setup)
        .insert_resource(ldtk::LevelSelection::Index(0))
        .run();
}

fn setup(mut commands: Commands, ass: Res<AssetServer>) {
    commands.spawn_bundle(OrthographicCameraBundle::new_2d());

    commands.spawn_bundle(ldtk::LdtkWorldBundle {
        ldtk_handle: ass.load("map.ldtk"),
        ..Default::default()
    });
}

Error message:

ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default    
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In CommandEncoder::copy_texture_to_texture
    Copy error
    copy of Y 368..384 would end up overrunning the bounds of the Source texture of Y size 373

', /home/work/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:2273:5
Trouv commented 2 years ago

It's possible you're running into the issue fixed here: https://github.com/StarArawn/bevy_ecs_tilemap/pull/151

Try patching the bevy_ecs_tilemap dependency:

[patch.crates-io]
bevy_ecs_tilemap = { git = "https://github.com/StarArawn/bevy_ecs_tilemap", rev = "d5169b6acf96d5f4a88592c3d6d24bde8ad724f6" }
igordreher commented 2 years ago

It works now with this patch, Thank you

bardt commented 2 years ago

For someone who finds this issue later. In Bevy 0.7 and bevy_ecs_ldtk 0.3 this rounding issue is solved and the patch is not needed (and doesn't work), but the overrunning the bounds panic still occurs. In my case, the root cause was that I used a tilemap with a tile spacing of 1px. Enabling atlas feature on bevy_ecs_ldtk solves it.

Ladvien commented 9 months ago

@bardt, I found this to be true of bevy = 0.12.0 and bevy_ecs_ldtk = 0.9.0. I really appreciate you taking time to document the issue.