@@ -52,6 +52,15 @@ pub use tcp::*;
5252/// Increased from 64MB to 256MB to handle large Arrow IPC responses from SQL queries.
5353pub const QUEUE_LEN : usize = 256 * 1024 * 1024 ;
5454
55+ /// The playback frequency used by the editor (frames per second).
56+ const PLAYBACK_FREQUENCY : f64 = 60.0 ;
57+
58+ /// The stream time-step that corresponds to 1x real-time playback at
59+ /// [`PLAYBACK_FREQUENCY`] Hz. `time_step * frequency == 1 second` of
60+ /// sim-time per second of wall-clock time.
61+ const REAL_TIME_STREAM_TIME_STEP : Duration =
62+ Duration :: from_nanos ( ( 1_000_000_000.0 / PLAYBACK_FREQUENCY ) as u64 ) ;
63+
5564#[ derive( Resource ) ]
5665pub struct PacketRx ( AsyncArcQueueRx ) ;
5766
@@ -184,7 +193,10 @@ fn sink_inner(
184193 . insert ( metadata. component_id , metadata) ;
185194 }
186195 * world_sink. db_config = metadata. db_config . clone ( ) ;
187- pending_stream_time_step = Some ( metadata. db_config . default_stream_time_step ) ;
196+ // Always start playback at 1x real-time speed regardless of
197+ // what the DB has stored. Playback speed is the requester's
198+ // concern; the DB should not dictate it.
199+ pending_stream_time_step = Some ( REAL_TIME_STREAM_TIME_STEP ) ;
188200 world_sink. commands . write_message ( DbMessage :: UpdateConfig ) ;
189201 }
190202 OwnedPacket :: Msg ( m) if m. id == LastUpdated :: ID => {
@@ -725,8 +737,8 @@ pub fn new_connection_packets(stream_id: StreamId) -> impl Iterator<Item = LenPa
725737 Stream {
726738 behavior : StreamBehavior :: FixedRate ( FixedRateBehavior {
727739 initial_timestamp : impeller2_wkt:: InitialTimestamp :: Earliest ,
728- timestep : Duration :: from_secs_f64 ( 1.0 / 60.0 ) . as_nanos ( ) as u64 ,
729- frequency : 60 ,
740+ timestep : REAL_TIME_STREAM_TIME_STEP . as_nanos ( ) as u64 ,
741+ frequency : PLAYBACK_FREQUENCY as u64 ,
730742 } ) ,
731743 id : stream_id,
732744 }
0 commit comments