gfx-rs/wgpu · error

Failed to read data file

Error message

Failed to read data file

What it means

Panic in DiskTraceLoader::load while replaying a trace: reading the referenced data file from the trace directory failed (missing file, permissions, or I/O error), so the replay cannot continue. The faulty input is the trace file path/data reference.

Source

Thrown at wgpu-core/src/device/trace/replay.rs:24

    fn load<'data>(&self, data: &'data Data) -> Cow<'data, [u8]>;
    fn load_utf8<'data>(&self, data: &'data Data) -> Cow<'data, str>;
}

#[cfg(feature = "std")]
pub struct DiskTraceLoader<'a>(&'a std::path::Path);

#[cfg(feature = "std")]
impl<'a> DiskTraceLoader<'a> {
    pub fn new(path: &'a std::path::Path) -> DiskTraceLoader<'a> {
        DiskTraceLoader(path)
    }
}

impl DataLoader for DiskTraceLoader<'_> {
    fn load<'data>(&self, data: &'data Data) -> Cow<'data, [u8]> {
        match data {
            Data::File(file) => {
                Cow::from(std::fs::read(self.0.join(file)).expect("Failed to read data file"))
            }
            Data::String(_, s) => Cow::from(s.as_bytes()),
            Data::Binary(_, b) => Cow::from(b),
        }
    }

    /// Load UTF-8 string data
    ///
    /// # Panics
    ///
    /// If the data kind is not a string format or the data is not valid UTF-8
    fn load_utf8<'data>(&self, data: &'data Data) -> Cow<'data, str> {
        match data {
            Data::File(file) => Cow::from(
                std::fs::read_to_string(self.0.join(file)).expect("Failed to read data file"),
            ),
            Data::String(kind, s) => {
                assert!(kind.is_string(), "{kind:?} cannot be loaded as a string");

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Verify the trace directory and all referenced data files exist and are readable before replaying
  2. Re-capture the trace if the referenced file was lost
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at wgpu-core/src/device/trace/replay.rs:24 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03). Data as JSON: /api/errors/4236ea95e68c22ad. Report an issue: GitHub.