Fix clock sync corruption caused by garbage data when outlet closes before inlet#150
Conversation
|
@mscheltienne, this PR also fixes the clock sync and sample count issues in the xdfs I'm looking at. I think truncating the IMO, it would be good to understand the In the case where the last clock offset may or may not be corrupted by the bug, but it is sometimes a correct offset, the logic in the PR makes sense. If it is the case that the |
Co-authored-by: Jesse Livezey <jesse.livezey@gmail.com>
|
@JesseLivezey I updated the wording. The rationale is that:
Regardless of the underlying |
To add to the previous reply, I think the additional sample does not always yield an additional clock offset measurement; but I think that when it does, it's always wrong. This is why the step (2) to identify a statistically abnormal clock offset is only performed if there is an additional sample. |
|
Right, I agree that the clock offset check should only happen if there is an extra sample.
OK, if that's the case, then I think the logic in this PR makes sense. FWIW, I looked at more xdf files that do contain extra samples in the streams. AFAICT, in 23/24 of the files, all final offsets for all streams look sensible in that they
In 1/24 of the files, only some of the streams with extra samples have corrupted clock offsets for the final sample. |
cbrnr
left a comment
There was a problem hiding this comment.
Beautiful! I only have a minor comment before merging.
|
@cbrnr Once merged, could you cut a release including this fix? I'd like to pin immediately our dependencies to this new version. Edit: if the bugs of 1.17.1 were fixed. |
|
@mscheltienne please add a changelog entry. Regarding a new release, sure, I can do that, and I think the bug in 1.17.1 has already been fixed by #140. We should add more details in the CHANGELOG regarding the problematic PR and which PRs get carried over to 1.17.2. Can you confirm that the bug in 1.17.1 is fixed on main? |
|
Thanks @mscheltienne! I'll try to consolidate the changelog and cut v1.17.2 today! |
|
@mscheltienne v1.17.2 is live! |
|
Thank you! |
When an LSL outlet is destroyed while an inlet is still connected,
liblslmay record an extra sample containing garbage (maybe garbage memory?). This extra sample can be accompanied by a corrupted clock offset measurement with nonsensical values (e.g., time jumping by ~800,000 seconds, offset value of ~-750,000 seconds).Since
pyxdfseems to use linear regression on clock offsets for synchronization, a single corrupted outlier can drastically skew the regression and produce incorrect timestamps for the entire stream.This PR adds automatic detection and correction:
sample_countSee: labstreaminglayer/pylsl#67
@JesseLivezey I think this fix is more robust than your proposal in #149 and also doesn't require the addition of a new argument to the API. Can you give it a shot?
I'll try to dig through
liblslto see if I can quickly get rid of this extra sample at its source, but in the meantime, @cboulay @cbrnr can you take a look at this PR detecting the problem on the reading side?