{"record":{"id":"77421df670ed97a2","repo":"slint-ui/slint","slug":"the-platform-abstraction-must-implement-duration-since-start","errorCode":null,"errorMessage":"The platform abstraction must implement `duration_since_start`","messagePattern":"The platform abstraction must implement `duration_since_start`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/core/platform.rs","lineNumber":118,"sourceCode":"    }\n\n    /// Returns the current time as a monotonic duration since the start of the program\n    ///\n    /// This is used by the animations and timer to compute the elapsed time.\n    ///\n    /// When the `std` feature is enabled, this function is implemented in terms of\n    /// [`std::time::Instant::now()`], but on `#![no_std]` platform, this function must\n    /// be implemented.\n    fn duration_since_start(&self) -> core::time::Duration {\n        #[cfg(feature = \"std\")]\n        {\n            let the_beginning = *INITIAL_INSTANT.get_or_init(time::Instant::now);\n            let now = time::Instant::now();\n            assert!(now >= the_beginning, \"The platform's clock is not monotonic!\");\n            now - the_beginning\n        }\n        #[cfg(not(feature = \"std\"))]\n        unimplemented!(\"The platform abstraction must implement `duration_since_start`\")\n    }\n\n    /// Returns the current interval to internal measure the duration to send a double click event.\n    ///\n    /// A double click event is a series of two pointer clicks.\n    fn click_interval(&self) -> core::time::Duration {\n        // 500ms is the default delay according to https://en.wikipedia.org/wiki/Double-click#Speed_and_timing\n        core::time::Duration::from_millis(500)\n    }\n\n    /// Returns the current rate at which the text cursor should flash or blink.\n    ///\n    /// This is the length of the entire visible-hidden-visible cycle, so for a duration of 1000ms\n    /// it is visible for 500ms then hidden for 500ms, then visible again.\n    ///\n    /// If this value is `Duration::ZERO` then the cycle is disabled.\n    fn cursor_flash_cycle(&self) -> core::time::Duration {\n        core::time::Duration::from_millis(1000)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/core/platform.rs#L100-L136","documentation":"Platform::duration_since_start's default implementation only works with the `std` feature; without std it is unimplemented!() to force platform implementors to provide a monotonic time source. This panic means a custom Platform on a no_std target did not override duration_since_start.","triggerScenarios":"Implementing the Platform trait for a no_std embedded target and not overriding duration_since_start, then Slint core requests the elapsed time (animations, timers, input timestamps).","commonSituations":"Bare-metal/embedded ports using the software renderer without std; bringing up a custom platform adapter where the time function was overlooked; copying a std-based Platform impl into a no_std build.","solutions":["Override duration_since_start in your Platform impl with a monotonic hardware tick (e.g. from a timer peripheral)","Return Duration from a monotonic counter initialized at platform startup","If std is actually available, rebuild with the `std` feature so the default implementation is compiled in"],"exampleFix":"// before\nstruct MyPlatform;\nimpl Platform for MyPlatform { /* no duration_since_start */ }\n// after\nimpl Platform for MyPlatform {\n    fn duration_since_start(&self) -> core::time::Duration {\n        core::time::Duration::from_millis(hardware_tick_ms())\n    }\n}","handlingStrategy":"validation","validationCode":"// compile-time: require an override on no_std\n#[cfg(not(feature = \"std\"))]\nconst _: () = {\n    // review checklist: Platform impls must override duration_since_start\n};","typeGuard":null,"tryCatchPattern":"// unimplemented! panics; the guard is implementing the trait method before first timer/animation use\nimpl Platform for MyPlatform {\n    fn duration_since_start(&self) -> core::time::Duration { Duration::from_millis(tick_ms()) }\n}","preventionTips":["When writing a no_std Platform, implement duration_since_start first, from a monotonic tick source","Enable the `std` feature when std is actually available","Exercise timers/animations early in embedded bring-up to catch missing overrides immediately"],"tags":["no-std","platform","embedded","unimplemented"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}