bevyengine/bevy · error · ChunkedUnevenCoreError
Need at least two unique samples to create a ChunkedUnevenCo
Error message
Need at least two unique samples to create a ChunkedUnevenCore, but {samples} were provided What it means
ChunkedUnevenCoreError::NotEnoughSamples is returned by ChunkedUnevenCore::new / new_width_inferred when the times list, after filtering to finite values, sorting, and deduplication, contains fewer than 2 unique entries. Like UnevenCore, interpolation needs a span between two distinct times; the reported `samples` is the post-filter unique count.
Source
Thrown at crates/bevy_math/src/curve/cores.rs:492
pub times: Vec<f32>,
/// The values that are used in sampling. Each width-worth of these correspond to a single sample.
///
/// # Invariants
/// The length of this vector must always be some fixed integer multiple of that of `times`.
pub values: Vec<T>,
}
/// An error that indicates that a [`ChunkedUnevenCore`] could not be formed.
#[derive(Debug, Error)]
#[error("Could not create a ChunkedUnevenCore")]
pub enum ChunkedUnevenCoreError {
/// The width of a `ChunkedUnevenCore` cannot be zero.
#[error("Chunk width must be at least 1")]
ZeroWidth,
/// At least two sample times are necessary to interpolate in `ChunkedUnevenCore`.
#[error(
"Need at least two unique samples to create a ChunkedUnevenCore, but {samples} were provided"
)]
NotEnoughSamples {
/// The number of samples that were provided.
samples: usize,
},
/// The length of the value buffer is supposed to be the `width` times the number of samples.
#[error("Expected {expected} total values based on width, but {actual} were provided")]
MismatchedLengths {
/// The expected length of the value buffer.
expected: usize,
/// The actual length of the value buffer.
actual: usize,
},
/// Tried to infer the width, but the ratio of lengths wasn't an integer, so no such length exists.
#[error("The length of the list of values ({values_len}) was not divisible by that of the list of times ({times_len})")]View on GitHub (pinned to 396ca72708)
Solutions
- Supply at least two distinct finite times.
- Filter NaN/INF timestamps before calling and assert you still have >= 2 unique values.
- Fix the time source if all timestamps collapse (e.g. delta-time accumulating as 0).
Example fix
// before
let core = ChunkedUnevenCore::new(vec![0.0, 0.0, 0.0], values, 3)?; // NotEnoughSamples { samples: 1 }
// after
let core = ChunkedUnevenCore::new(vec![0.0, 0.5, 1.0], values, 3)?; Defensive patterns
Strategy: validation
Validate before calling
let unique_finite: Vec<f32> = {
let mut v: Vec<f32> = times.iter().copied().filter(f32::is_finite).collect();
v.sort_by(|a, b| a.total_cmp(b));
v.dedup();
v
};
if unique_finite.len() >= 2 {
let core = ChunkedUnevenCore::new(times, values, width)?;
} Try / catch
match ChunkedUnevenCore::new(times, values, width) {
Ok(core) => core,
Err(ChunkedUnevenCoreError::NotEnoughSamples { samples }) => {
warn!("need >= 2 unique finite times, {samples} survived filtering");
return Ok(());
}
Err(e) => return Err(e.into()),
} Prevention
- Filter and dedup times before construction and assert >= 2 remain.
- Investigate timestamp collapse early: identical frame times usually mean a stuck clock.
- Sanitize NaN timestamps where they are produced, not where they are consumed.
When it happens
Trigger: Passing times such as vec![0.0, 0.0, 0.0], times containing only NaN/INF entries, or a single timestamp; both constructors hit it via filter_sort_dedup_times before the length checks.
Common situations: All keyframes sharing one timestamp (same-frame events); NaN timestamps from upstream math; clock reset bugs that stamp every sample with time 0.0.
Related errors
- Need at least two unique samples to create an UnevenCore, bu
- The resulting interval would be invalid (empty or with a NaN
- Not enough data to build curve: needed at least {expected} c
- Could not construct an EvenCore
- Need at least two samples to create an EvenCore, but {sample
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/92f4ebef1c78241a.
Report an issue: GitHub.