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

Make sure to always write out end-of-stream markers during encoding #7796

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

teh-cmc
Copy link
Member

@teh-cmc teh-cmc commented Oct 17, 2024

Saving Rerun RRD data can happen in many, many different ways, and it must always make sure to include the end-of-stream marker.
This is unfortunately not trivial because many things want to partial move out of Encoder, which rules out impl Drop.

This PR introduces a DroppableEncoder that can be used in many cases, or makes sure to properly finish() otherwise.

This fixes half of the issues described in:

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!
  • If have noted any breaking changes to the log API in CHANGELOG.md and the migration guide

To run all checks from main, comment on the PR with @rerun-bot full-check.

@teh-cmc
Copy link
Member Author

teh-cmc commented Oct 17, 2024

@rerun-bot full-check

Copy link

Started a full build: https://github.com/rerun-io/rerun/actions/runs/11381591566

@teh-cmc teh-cmc changed the title wip Make sure to always write out end-of-stream markers during encoding Oct 17, 2024
@teh-cmc teh-cmc added 🪳 bug Something isn't working exclude from changelog PRs with this won't show up in CHANGELOG.md 🪵 Log & send APIs Affects the user-facing API for all languages labels Oct 17, 2024
@teh-cmc teh-cmc marked this pull request as ready for review October 17, 2024 08:59
@teh-cmc
Copy link
Member Author

teh-cmc commented Oct 17, 2024

I can confirm this fixes the File > Save feature, and as far as I can tell doesn't break anything otherwise...

@@ -120,15 +179,20 @@ impl<W: std::io::Write> Encoder<W> {
}
}

// NOTE: This cannot be done in a `Drop` implementation because of `Self::into_inner` which
// does a partial move.
#[inline]
pub fn finish(&mut self) -> Result<(), EncodeError> {
MessageHeader::EndOfStream.encode(&mut self.write)?;
Ok(())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could warn in Drop if this hasn't been called, at least in debug builds

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean? We cannot implement Drop for Encoder?

crates/store/re_log_encoding/src/encoder.rs Show resolved Hide resolved
crates/store/re_log_encoding/src/encoder.rs Outdated Show resolved Hide resolved
@teh-cmc teh-cmc merged commit 8233130 into main Oct 17, 2024
28 checks passed
@teh-cmc teh-cmc deleted the cmc/add_eos_on_save branch October 17, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working exclude from changelog PRs with this won't show up in CHANGELOG.md 🪵 Log & send APIs Affects the user-facing API for all languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants