You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seldom-SE opened this issue
Apr 25, 2023
· 5 comments
Labels
A-TimeInvolves time keeping and reportingC-BugAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) buildsS-BlockedThis cannot move forward until something else changes
Attempted to represent an Instant that is before app startup by subtracting a Duration.
What went wrong
A panic due to subtraction with overflow!
Additional information
I have a feature in seldom_pixel that pre-simulates particles when you spawn an emitter. So, when something that emits particles gets close to being on-screen or a scene is spawned with an emitter already on-screen, you can spawn an emitter at that moment, and it will look like the particles were already there. Particles store the time they were spawned for their functionality, which means that pre-simulated particles may store a time before they were actually spawned.
On wasm, I can't represent particles that were spawned with pre-simulation too close to app startup, since that moment is not representable with Instant. Not a major issue, but it's hacky to workaround. A possible solution on my end would be to use f32s instead, or add a buffer to every time.last_update call. If it's possible, a solution on Bevy's end would be to start time somewhere after 0. A minute should suffice for me, but I think it wouldn't be a dent on Instant's range to start many years in.
The text was updated successfully, but these errors were encountered:
But also, it's maybe not supposed to work in native either, and will panic on other platforms depending on how much time you subtract
mockersf
added
S-Blocked
This cannot move forward until something else changes
and removed
D-Complex
Quite challenging from either a design or technical perspective. Ask for help!
labels
Apr 25, 2023
[..] The starting point of the underlying clock is not defined by Rust.
The reason this currently works on Linux is because std uses clock_gettime:
All implementations support the system-wide realtime clock, which is identified by CLOCK_REALTIME. Its time represents seconds and nanoseconds since the Epoch.
So the starting time is since the UNIX epoch. So unless your computer boots with a time set to 1970 it will always be much bigger then 0.
On Windows for example, std uses QueryPerformanceCounter, which doesn't start from the UNIX epoch, 0 can be the start of when you boot. [..]
ERROR app: panicked at /home/seldom/.cargo/registry/src/index.crates.io-6f17d22bba15001f/web-time-0.2.4/src/time/insta
nt.rs:93:14:
overflow when subtracting duration from instant
As pointed out in #8483 (comment) this isn't an issue with instant or web-time, but with the guarantees std::time::Instant gives, which both libraries try to emulate as closely as possible.
If Bevy wants to resolve this issue, it has to move away from std::time::Instant.
A-TimeInvolves time keeping and reportingC-BugAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) buildsS-BlockedThis cannot move forward until something else changes
Bevy version
0.10
Relevant system information
WebAssembly
What you did
Attempted to represent an
Instant
that is before app startup by subtracting aDuration
.What went wrong
A panic due to subtraction with overflow!
Additional information
I have a feature in
seldom_pixel
that pre-simulates particles when you spawn an emitter. So, when something that emits particles gets close to being on-screen or a scene is spawned with an emitter already on-screen, you can spawn an emitter at that moment, and it will look like the particles were already there. Particles store the time they were spawned for their functionality, which means that pre-simulated particles may store a time before they were actually spawned.On wasm, I can't represent particles that were spawned with pre-simulation too close to app startup, since that moment is not representable with
Instant
. Not a major issue, but it's hacky to workaround. A possible solution on my end would be to usef32
s instead, or add a buffer to everytime.last_update
call. If it's possible, a solution on Bevy's end would be to start time somewhere after 0. A minute should suffice for me, but I think it wouldn't be a dent onInstant
's range to start many years in.The text was updated successfully, but these errors were encountered: