-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix(dgw): fix streamer failure for RDM #1184
base: master
Are you sure you want to change the base?
Conversation
Let maintainers know that an action is required on their side
|
7d95d85
to
6b0e511
Compare
author irving ou <[email protected]> 1736528540 -0500 committer irving ou <[email protected]> 1736530356 -0500 fix(dgw): fix streamer failure for RDM
b06d2e4
to
41b81a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply this: https://github.com/Devolutions/IronRDP/blob/dd249909a894004d4f728d30b3a4aa77a0f8193b/STYLE.md#logging
I understand CutBlockHitMarker is a type token for ensuring we are only calling mark_cut_block_hit
at most once per call to into_encoded_writer
. This token is stored in an Option
slot and taken out when webm_itr.last_tag_position() == cut_block_position
.
I’m also not grokking fully this part as cut_block_position
is itself the result of calling webm_itr.last_tag_position()
prior to iterating? Suggesting that webm_itr.last_tag_position() == cut_block_position
is always true. Am I missing something?
The problem was that mark_cut_block_hit()
was called more than once, but why is it happening exactly? Breaking out of the loop and calling the function without relying on a dynamic state (via the Option
) would be much more clean for instance.
When you asked why the "cut block" would be hit twice, it was a great question. Initially, I wasn’t entirely sure what was happening. While making this PR, I observed changes in the value of the tag emitted by the iterator. Specifically, during iteration, the tag iterator would emit a Answer to Your QuestionThe issue is related to a commit I made to the ExplanationWhen the end of a file (EOF) is reached, However, this leads to a problem in a specific case: What happens if we aren’t reading from a In this situation:
Reproducing the IssueHere’s a short Rust example to reproduce this scenario: use std::fs::File;
use std::io::SeekFrom;
fn main() {
let mut src = File::open(r"C:\ProgramData\Devolutions\Gateway\recordings\d2644cb0-63c3-412d-a040-cf4cb8b042e9\recording-0.webm").unwrap();
src.seek(SeekFrom::Start(138)).unwrap();
let mut tag_iterator = WebmIterator::new(&mut src, &[MatroskaSpec::BlockGroup(Master::Start)]);
tag_iterator.emit_master_end_when_eof(true);
println!("Start");
while let Some(tag) = tag_iterator.next() {
let name = webm_cutter::debug::mastroka_spec_name(&tag.unwrap());
let offset = tag_iterator.last_emitted_tag_offset();
println!("Tag: {:?}, offset = {}", name, offset);
}
} Output
SolutionThe fix is simple: disable the emission of master end tags when EOF is reached by adding this line: tag_iterator.emit_master_end_when_eof(false); This ensures that the Keep the MarkerKeeping the marker is still important because the "cut block" should only ever be hit once. This behavior ensures correctness in the streaming and cutting logic. |
I will address other concerns in the comments |
Oh, yes, and |
Changelog: ignore