-
Notifications
You must be signed in to change notification settings - Fork 63
Fix IIRFilter crash on silent blocks #477
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
Conversation
jdm
left a comment
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.
I was confused why these changes worked and the original code did not. I have come to the conclusion that Chunk::explicit_silence contains a bug that this PR is working around, and I would rather see us fix the bug properly.
Line 45 in b0d3b74
| let blocks: SmallVec<[Block; 1]> = SmallVec::new(); |
blocks contains one element, but we never actually push that element. The crash should go away if we fix that.
Yes, I will debug Chunk::explicit_silence further |
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
1394d29 to
a08ed18
Compare
Good catch, indeed, before |
Fix IIRFilter crash on silent blocks and add crash test.
Before fix: `let blocks: SmallVec<[Block; 1]> = SmallVec::new();`
followed by `blocks.as_slice().iter().map(.)`, Because blocks was empty,
the iterator never produced anything, so the resulting Chunk had zero
blocks and caused:
```
panic: index out of bounds: the len is 0 but the index is 0 (thread AudioRenderThread, at /home/runner/.cargo/git/checkouts/media-9074def3f0bdf023/b0d3b74/audio/iir_filter_node.rs:173)
```
Now: we still use SmallVec<[Block; 1]>, but we actually push a block
into it before returning: create Block::default(), call
explicit_silence() on it, blocks.push(block), then Chunk { blocks }.
This ensures the chunk contains one explicit silent block, which is what
downstream code expects.
Actual fix is in:
servo/media#477
This PR uses the new media version containing fix and added crash test.
Testing: added crash test.
Fixes: #41085
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Fix IIRFilter crash on silent blocks and add crash test.
Before fix: `let blocks: SmallVec<[Block; 1]> = SmallVec::new();`
followed by `blocks.as_slice().iter().map(.)`, Because blocks was empty,
the iterator never produced anything, so the resulting Chunk had zero
blocks and caused:
```
panic: index out of bounds: the len is 0 but the index is 0 (thread AudioRenderThread, at /home/runner/.cargo/git/checkouts/media-9074def3f0bdf023/b0d3b74/audio/iir_filter_node.rs:173)
```
Now: we still use SmallVec<[Block; 1]>, but we actually push a block
into it before returning: create Block::default(), call
explicit_silence() on it, blocks.push(block), then Chunk { blocks }.
This ensures the chunk contains one explicit silent block, which is what
downstream code expects.
Actual fix is in:
servo/media#477
This PR uses the new media version containing fix and added crash test.
Testing: added crash test.
Fixes: #41085
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Fix IIRFilter crash on silent blocks and add crash test.
Before fix: `let blocks: SmallVec<[Block; 1]> = SmallVec::new();`
followed by `blocks.as_slice().iter().map(.)`, Because blocks was empty,
the iterator never produced anything, so the resulting Chunk had zero
blocks and caused:
```
panic: index out of bounds: the len is 0 but the index is 0 (thread AudioRenderThread, at /home/runner/.cargo/git/checkouts/media-9074def3f0bdf023/b0d3b74/audio/iir_filter_node.rs:173)
```
Now: we still use SmallVec<[Block; 1]>, but we actually push a block
into it before returning: create Block::default(), call
explicit_silence() on it, blocks.push(block), then Chunk { blocks }.
This ensures the chunk contains one explicit silent block, which is what
downstream code expects.
Actual fix is in:
servo/media#477
This PR uses the new media version containing fix and added crash test.
Testing: added crash test.
Fixes: #41085
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
fixes servo/servo#41085