{"record":{"id":"ae4c837bb74d8543","repo":"kitao/pyxel","slug":"layer-dimensions-are-too-large-in-file-path","errorCode":null,"errorMessage":"Layer dimensions are too large in file '{path}'","messagePattern":"Layer dimensions are too large in file '(.+?)'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pyxel-core/src/tmx_parser.rs","lineNumber":88,"sourceCode":"        .columns\n        .ok_or_else(|| err(\"No embedded tileset in file\"))?;\n\n    let layer = tmx\n        .layers\n        .get(layer_index as usize)\n        .ok_or_else(|| format!(\"Layer {layer_index} not found in file '{path}'\"))?;\n    if layer.data.encoding != \"csv\" {\n        return Err(err(\"Unsupported encoding in file\"));\n    }\n\n    let tile_ids: Vec<u32> = remove_whitespace(&layer.data.tiles)\n        .split(',')\n        .map(|s| s.parse::<u32>().map_err(|_| err(\"Failed to parse file\")))\n        .collect::<Result<_, _>>()?;\n\n    // Convert TMX global tile IDs into Pyxel image tile coordinates.\n    let tilemap = Tilemap::try_new(layer.width, layer.height, ImageSource::Index(0))\n        .map_err(|_| err(\"Layer dimensions are too large in file\"))?;\n    let mut tilemap_ref = rc_mut!(tilemap);\n    for (y, row) in tile_ids.chunks(layer.width as usize).enumerate() {\n        for (x, &id) in row.iter().enumerate() {\n            let id = (id & !TMX_TILE_FLAG_MASK).saturating_sub(tileset.firstgid);\n            tilemap_ref.canvas.write_data(\n                x,\n                y,\n                (\n                    (id % columns) as ImageTileCoord,\n                    (id / columns) as ImageTileCoord,\n                ),\n            );\n        }\n    }\n    drop(tilemap_ref);\n    Ok(tilemap)\n}\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/kitao/pyxel/blob/50f9bd77780c993aca62b5b221766bde5791081d/crates/pyxel-core/src/tmx_parser.rs#L70-L106","documentation":"Tilemap::try_new rejected the layer's width/height, likely because they exceed Pyxel Tilemap limits (Pyxel tilemaps are bounded, e.g. 256x256 or similar constraints depending on settings). The parser surfaces the constructor failure as 'Layer dimensions are too large'. The TMX layer itself may be valid, but it cannot fit into a Pyxel tilemap.","triggerScenarios":"parse_tmx calls Tilemap::try_new(layer.width, layer.height, ImageSource::Index(0)) and the TMX layer's @width/@height exceed the Tilemap implementation's maximum dimensions, so try_new returns Err.","commonSituations":"Large game maps exported straight from Tiled (e.g. 512x512 layers); importing an entire world map instead of a screen-sized chunk; migrating a project built for a different engine with no Pyxel size limits.","solutions":["Split the large TMX layer into chunks that fit within Pyxel Tilemap limits and load them as separate tilemaps","Check crate::settings / Tilemap::try_new for the maximum supported dimensions and resize the map in Tiled accordingly","Load only a sub-rectangle of the layer by pre-cropping the TMX data before parsing","If the map legitimately needs to be larger, extend or replace Tilemap's storage instead of relying on parse_tmx"],"exampleFix":"// before: one 512x512 layer in Tiled\n<layer width=\"512\" height=\"512\" ...>\n// after: two 256x512 layers loaded separately\n<layer width=\"256\" height=\"512\" ...>\n// parse each with parse_tmx(path, 0) and parse_tmx(path, 1)","handlingStrategy":"validation","validationCode":"fn layer_fits(tmx_path: &str, max: u32) -> std::io::Result<bool> {\n    let xml = std::fs::read_to_string(tmx_path)?;\n    let fits = xml.split(\"<layer\").skip(1).all(|s| {\n        let w = s.split(\"width=\").nth(1)\n            .and_then(|v| v.trim_start_matches('\\\"').split('\\\"').next())\n            .and_then(|v| v.parse::<u32>().ok());\n        let h = s.split(\"height=\").nth(1)\n            .and_then(|v| v.trim_start_matches('\\\"').split('\\\"').next())\n            .and_then(|v| v.parse::<u32>().ok());\n        w.map_or(true, |w| w <= max) && h.map_or(true, |h| h <= max)\n    });\n    Ok(fits)\n}","typeGuard":null,"tryCatchPattern":"match parse_tmx(path, layer_index) {\n    Ok(t) => t,\n    Err(msg) if msg.contains(\"too large\") => {\n        eprintln!(\"split layer into Pyxel-sized chunks: {msg}\");\n        return Err(msg);\n    }\n    Err(msg) => return Err(msg),\n}","preventionTips":["Keep Tiled layers within Pyxel Tilemap maximum dimensions when authoring","Split world maps into chunk files of supported size","Check layer width/height attributes during asset import in CI"],"tags":["tmx","tilemap","dimensions","limit-exceeded"],"backgroundTag":"dimension-limit-exceeded","analyzedSha":"50f9bd77780c993aca62b5b221766bde5791081d","analyzedAt":"2026-09-03T10:27:43.285Z","contentChangedAt":"2026-09-03T10:27:43.285Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}