{"record":{"id":"0a77bb483913636b","repo":"bevyengine/bevy","slug":"an-elapsed-time-getter-has-not-been-provided-to-i","errorCode":null,"errorMessage":"An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`","messagePattern":"An elapsed time getter has not been provided to `Instant`\\. Please use `Instant::set_elapsed\\(\\.\\.\\.\\)` before calling `Instant::now\\(\\)`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_platform/src/time/fallback.rs","lineNumber":177,"sourceCode":"        }\n        #[cfg(target_arch = \"x86_64\")] => {\n            // SAFETY: standard technique for getting a nanosecond counter on x86_64\n            let nanos = unsafe {\n                core::arch::x86_64::_rdtsc()\n            };\n            Duration::from_nanos(nanos)\n        }\n        #[cfg(target_arch = \"aarch64\")] => {\n            // SAFETY: standard technique for getting a nanosecond counter of aarch64\n            let nanos = unsafe {\n                let mut ticks: u64;\n                core::arch::asm!(\"mrs {}, cntvct_el0\", out(reg) ticks);\n                ticks\n            };\n            Duration::from_nanos(nanos)\n        }\n        _ => {\n            panic!(\"An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`\")\n        }\n    }\n}\n","sourceCodeStart":159,"sourceCodeEnd":181,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_platform/src/time/fallback.rs#L159-L181","documentation":"bevy_platform's fallback `Instant::now` reads a per-architecture monotonic counter via `unset_getter` (crates/bevy_platform/src/time/fallback.rs:151): `rdtsc` on x86/x86_64, `cntvct_el0` on aarch64. On every other architecture the `_` arm panics with this message — the only supported path there is to install a platform-specific elapsed-time getter with `Instant::set_elapsed(...)` before the first `now()` call.","triggerScenarios":"Compiling with the fallback time implementation (no_std, web feature off, std time unavailable) for a target that is not x86, x86_64, or aarch64 — e.g. riscv32/riscv64, 32-bit arm, powerpc — and touching `Instant::now()`/`Instant::update()` (Bevy's Time plugin does this at startup), without calling `Instant::set_elapsed` first.","commonSituations":"Embedded/no_std Bevy ports or crates depending on bevy_platform built for exotic targets; CI cross-compile checks that actually run tests on riscv/arm bare-metal; switching a no_std project from a supported to an unsupported architecture.","solutions":["Before any time use, register a monotonic getter: `Instant::set_elapsed(|| read_cycle_counter_as_duration())`","Prefer enabling a real time source for the target (std `Instant` or the web time feature) instead of the fallback","If the platform has no counter, build without the code paths that call `Instant::now()`"],"exampleFix":"// before: riscv no_std target, first Instant::now() panics\n// after: install a cycle-counter-based getter at startup\nInstant::set_elapsed(|| {\n    let ticks: u64;\n    unsafe { core::arch::asm!(\"csrr {0}, cycle\", out(reg) ticks) };\n    Duration::from_nanos(ticks / CLOCKS_PER_SEC_NANO) // scaled to nanos\n});\nlet now = Instant::now();","handlingStrategy":"validation","validationCode":"// compile-time guard for fallback-time targets\n#[cfg(all(\n    not(target_arch = \"x86\"),\n    not(target_arch = \"x86_64\"),\n    not(target_arch = \"aarch64\"),\n    not(feature = \"web\")\n))]\ncompile_error!(\"bevy_platform fallback Instant needs Instant::set_elapsed on this arch\");\n\n// runtime: install the getter before anything calls now()\nInstant::set_elapsed(read_monotonic_counter);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call Instant::set_elapsed as the first statement of main on no_std targets without built-in counters","Cross-compile CI (`cargo build --target riscv64imac-unknown-none-elf`) to catch unsupported-arch panics early","Prefer the std or web time feature whenever the target allows it"],"tags":["bevy","no-std","platform-support","instant","panic","time"],"backgroundTag":"unsupported-target-architecture","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}