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

Rust SDK silently drops data in some situations #2627

Closed
emilk opened this issue Jul 7, 2023 · 2 comments · Fixed by #2632
Closed

Rust SDK silently drops data in some situations #2627

emilk opened this issue Jul 7, 2023 · 2 comments · Fixed by #2632
Labels
🪳 bug Something isn't working 🦀 Rust API Rust logging API

Comments

@emilk
Copy link
Member

emilk commented Jul 7, 2023

Minimal reproduce:

use rerun::{
    components::{ColorRGBA, Point3D},
    time::{TimeType, Timeline},
    MsgSender, RecordingStreamBuilder,
};

fn main() -> anyhow::Result<()> {
    rerun::external::re_log::setup_native_logging();

    let (rec_stream, storage) = RecordingStreamBuilder::new("images").memory()?;
    let timeline = Timeline::new("keyframe", TimeType::Sequence);

    let pt = Point3D {
        x: 1.0,
        y: 1.0,
        z: 1.0,
    };

    MsgSender::new("world/pts")
        .with_time(timeline, 1)
        .with_component(&[pt])?
        .with_splat(ColorRGBA::from_rgb(161, 34, 212))?
        .send(&rec_stream)?;

    rerun::native_viewer::show(storage.take())?;

    Ok(())
}

Results in this:

image

Seems like data is lost somehow. Some flushing that is not being done?

@emilk emilk added 🪳 bug Something isn't working 👀 needs triage This issue needs to be triaged by the Rerun team 🦀 Rust API Rust logging API and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Jul 7, 2023
@emilk emilk self-assigned this Jul 7, 2023
@emilk
Copy link
Member Author

emilk commented Jul 7, 2023

Adding a call to rec_stream.flush_blocking(); before storage.take(); solves it.

We should at least warn when data is being silently lost, and document the behavior properly.

Maybe we could make take() block until data is flushed.

@emilk emilk removed their assignment Jul 7, 2023
@emilk emilk changed the title Data missing when using Rust SDK Rust SDK silently drops data in some situations Jul 7, 2023
@teh-cmc
Copy link
Member

teh-cmc commented Jul 7, 2023

Yeah, I think the most user-friendly solution here would be to do the same thing we do in the jupyter notebook internals in Python, namely: internally keep track of the RecordingStream associated with this MemorySinkStorage, and flush on behalf of the user where it makes sense.

It's a bit blurry how all of this works though, I'll have a quick look to see what's possible.

teh-cmc added a commit that referenced this issue Jul 7, 2023
Fixes #2627 
Should supersede #2630 

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2632) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2632)
- [Docs
preview](https://rerun.io/preview/pr%3Acmc%2Fautoflushmagix/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Acmc%2Fautoflushmagix/examples)
emilk added a commit that referenced this issue Jul 10, 2023
…memory sink (#2630)

See:
* #2627

I added some log warnings too, but they are not sufficient. If there is
no call to `flush_blocking`, data is still silently dropped somehow.
Maybe @teh-cmc has some idea where?

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2630) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2630)
- [Docs
preview](https://rerun.io/preview/pr%3Aemilk%2Fdocument-flush/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aemilk%2Fdocument-flush/examples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working 🦀 Rust API Rust logging API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants