Skip to content

Commit 4aff4fa

Browse files
authored
rerun rrd compact: always put blueprints at the start of the recordings (#6998)
Slight modification to `rerun rrd compact` in order to make sure that, if the recording contains one or more blueprints, they end up at the beginning of it, otherwise the experience would suck since the blueprint would only get loaded once all the data had finished streaming in.
1 parent 1b4e171 commit 4aff4fa

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

crates/top/rerun/src/run.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use itertools::{izip, Itertools};
99

1010
use re_data_source::DataSource;
1111
use re_log_types::{LogMsg, SetStoreInfo};
12-
use re_sdk::log::Chunk;
12+
use re_sdk::{log::Chunk, StoreKind};
1313
use re_smart_channel::{ReceiveSet, Receiver, SmartMessagePayload};
1414

1515
#[cfg(feature = "web_viewer")]
@@ -661,16 +661,32 @@ fn run_compact(path_to_input_rrd: &Path, path_to_output_rrd: &Path) -> anyhow::R
661661
let mut rrd_out = std::fs::File::create(path_to_output_rrd)
662662
.with_context(|| format!("{path_to_output_rrd:?}"))?;
663663

664-
let messages: Result<Vec<Vec<LogMsg>>, _> = entity_dbs
665-
.into_values()
664+
let messages_rbl: Result<Vec<Vec<LogMsg>>, _> = entity_dbs
665+
.values()
666+
.filter(|entity_db| entity_db.store_kind() == StoreKind::Blueprint)
666667
.map(|entity_db| entity_db.to_messages(None /* time selection */))
667668
.collect();
668-
let messages = messages?;
669-
let messages = messages.iter().flatten();
669+
let messages_rbl = messages_rbl?;
670+
let messages_rbl = messages_rbl.iter().flatten();
671+
672+
let messages_rrd: Result<Vec<Vec<LogMsg>>, _> = entity_dbs
673+
.values()
674+
.filter(|entity_db| entity_db.store_kind() == StoreKind::Recording)
675+
.map(|entity_db| entity_db.to_messages(None /* time selection */))
676+
.collect();
677+
let messages_rrd = messages_rrd?;
678+
let messages_rrd = messages_rrd.iter().flatten();
670679

671680
let encoding_options = re_log_encoding::EncodingOptions::COMPRESSED;
672-
re_log_encoding::encoder::encode(version, encoding_options, messages, &mut rrd_out)
673-
.context("Message encode")?;
681+
re_log_encoding::encoder::encode(
682+
version,
683+
encoding_options,
684+
// NOTE: We want to make sure all blueprints come first, so that the viewer can immediately
685+
// set up the viewport correctly.
686+
messages_rbl.chain(messages_rrd),
687+
&mut rrd_out,
688+
)
689+
.context("Message encode")?;
674690

675691
let rrd_out_size = rrd_out.metadata().ok().map(|md| md.len());
676692

0 commit comments

Comments
 (0)