Skip to content

Conversation

@Taym95
Copy link
Member

@Taym95 Taym95 commented Dec 5, 2025

Copy link
Member

@jdm jdm left a 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.

let blocks: SmallVec<[Block; 1]> = SmallVec::new();
is written with an assumption that blocks contains one element, but we never actually push that element. The crash should go away if we fix that.

@Taym95
Copy link
Member Author

Taym95 commented Dec 6, 2025

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.

let blocks: SmallVec<[Block; 1]> = SmallVec::new();

is written with an assumption that 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>
@Taym95 Taym95 force-pushed the fix-iir-filter-silence-crash branch from 1394d29 to a08ed18 Compare December 6, 2025 15:38
@Taym95
Copy link
Member Author

Taym95 commented Dec 6, 2025

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.

let blocks: SmallVec<[Block; 1]> = SmallVec::new();

is written with an assumption that blocks contains one element, but we never actually push that element. The crash should go away if we fix that.

Good catch, indeed, before let blocks: SmallVec<[Block; 1]> = SmallVec::new(); followed by blocks.as_slice().iter().mapp() and since blocks was empty the iterator never produced anything, so the resulting Chunk had zero blocks, this should be fixed now.

@Taym95 Taym95 requested a review from jdm December 6, 2025 15:52
@Taym95 Taym95 added this pull request to the merge queue Dec 6, 2025
@Taym95 Taym95 removed this pull request from the merge queue due to a manual request Dec 6, 2025
@Taym95 Taym95 added this pull request to the merge queue Dec 6, 2025
Merged via the queue into servo:main with commit 06be485 Dec 6, 2025
3 checks passed
github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Dec 6, 2025
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>
github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Dec 6, 2025
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>
github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Dec 6, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants