Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subtract out of bounds #586

Closed
TobiasEnholmX opened this issue Jul 18, 2023 · 4 comments
Closed

subtract out of bounds #586

TobiasEnholmX opened this issue Jul 18, 2023 · 4 comments
Assignees
Labels
bug Something isn't working topic:animation Animations
Milestone

Comments

@TobiasEnholmX
Copy link
Contributor

[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Running startup event for module: fpsmovement_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Loading module: console_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Done loading module: fpsaudio_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Done loading module: fpsmodel_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Running startup event for module: fpsaudio_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Running startup event for module: fpsmodel_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Done loading module: fpsui_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Running startup event for module: fpsui_client
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Done loading module: console_client
[2023-07-18T15:31:26Z INFO  ambient::client::wasm] [fpsmodel_client] stdout: ___model loaded___
[2023-07-18T15:31:26Z INFO  ambient::client::wasm] [fpsmodel_client] stdout: ___model loaded___
[2023-07-18T15:31:26Z INFO  ambient::client::wasm] [fpsmodel_client] stdout: ___model loaded___
[2023-07-18T15:31:26Z INFO  ambient::client::wasm] [fpsmodel_client] stdout: ___model loaded___
[2023-07-18T15:31:26Z INFO  ambient::client::wasm] [fpsmodel_client] stdout: ___model loaded___
[2023-07-18T15:31:26Z INFO  ambient_wasm::shared] Running startup event for module: console_client
[2023-07-18T15:31:28Z INFO  ambient::client::wasm] [fpsmodel_client] stdout: ___model loaded___
[2023-07-18T15:32:27Z INFO  ambient::client::wasm] [fpsmodel_client] stdout: ___model loaded___
thread 'main' panicked at 'overflow when subtracting durations', library/core/src/time.rs:936:31
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic_display
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:150:5
   3: core::panicking::panic_str
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:134:5
   4: core::option::expect_failed
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/option.rs:2025:5
   5: core::option::Option<T>::expect
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/option.rs:913:21
   6: <core::time::Duration as core::ops::arith::Sub>::sub
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/time.rs:936:31
   7: ambient_animation::player::sample_animation_node
   8: ambient_ecs::query::TypedReadQuery<R>::to_system_with_name::{{closure}}
   9: <ambient_ecs::query::SystemGroup<E> as ambient_ecs::query::System<E>>::run
  10: <ambient_ecs::query::SystemGroup<E> as ambient_ecs::query::System<E>>::run
  11: <ambient_ecs::query::SystemGroup<E> as ambient_ecs::query::System<E>>::run
  12: ambient_network::client_game_state::ClientGameState::on_frame
  13: <ambient_network::native::client::ClientView as ambient_element::ElementComponent>::render::{{closure}}
  14: ambient_element::tree::ElementTree::update
  15: ambient_ecs::query::TypedReadQuery<R>::to_system_with_name::{{closure}}
  16: <ambient_ecs::query::SystemGroup<E> as ambient_ecs::query::System<E>>::run
  17: <ambient_ecs::query::SystemGroup<E> as ambient_ecs::query::System<E>>::run
  18: <ambient_ecs::query::SystemGroup<E> as ambient_ecs::query::System<E>>::run
  19: ambient_app::App::handle_static_event
  20: ambient_app::App::run_blocking::{{closure}}
  21: <winit::platform_impl::platform::app_state::EventLoopHandler<T> as winit::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event
  22: winit::platform_impl::platform::app_state::Handler::handle_nonuser_event
  23: winit::platform_impl::platform::app_state::AppState::cleared
  24: std::panicking::try
  25: winit::platform_impl::platform::observer::control_flow_end_handler
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: <unknown>
  30: <unknown>
  31: <unknown>
  32: <unknown>
  33: <unknown>
  34: <unknown>
  35: <unknown>
  36: winit::platform_impl::platform::event_loop::EventLoop<T>::run
  37: ambient_app::App::run_blocking
  38: ambient::main::{{closure}}
  39: tokio::runtime::park::CachedParkThread::block_on
  40: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  41: ambient::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[2023-07-18T15:33:09Z INFO  ambient::client] Disconnecting client
tobiasenholm@Tobiass-MacBook-Pro afps % 
@philpax philpax added bug Something isn't working topic:animation Animations labels Jul 18, 2023
@philpax philpax added this to the 0.3 milestone Aug 31, 2023
@pierd
Copy link
Contributor

pierd commented Aug 31, 2023

I believe that the source of this is different clocks on server and client.

When PlayClipFromUrlNode is used on the server, it will use server's clock for start_time component, which is then sent over to the client. Then on the client a slightly different clock can be used to actually play the animation meaning that time can be before start_time causing this overflow. If time is after start_time then it won't crash but still cause a glitch.

@philpax
Copy link
Contributor

philpax commented Sep 11, 2023

@pierd What do you think are the odds of getting synchronised clocks in? I'm not confident, so I'm thinking we should just hack around this by using a saturating subtract so that it doesn't panic.

@pierd pierd self-assigned this Sep 12, 2023
@pierd
Copy link
Contributor

pierd commented Sep 12, 2023

@philpax clock sync is not that complex (but not trivial to get right) but the list is just getting longer so I wouldn't bet on it. I agree - we should make it not crash first even if we get potential glitches (in theory we got them already anyway).

@pierd
Copy link
Contributor

pierd commented Sep 12, 2023

There's really no downside to saturating sub in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic:animation Animations
Projects
None yet
Development

No branches or pull requests

3 participants