Skip to content

core: Fix NetStream playback stalling when play() is called after EOF#23390

Open
turicfr wants to merge 3 commits intoruffle-rs:masterfrom
turicfr:netstream_bug
Open

core: Fix NetStream playback stalling when play() is called after EOF#23390
turicfr wants to merge 3 commits intoruffle-rs:masterfrom
turicfr:netstream_bug

Conversation

@turicfr
Copy link
Copy Markdown
Contributor

@turicfr turicfr commented Apr 4, 2026

When a NetStream naturally reaches the end of a video, it synchronously dispatches a NetStream.Play.Stop status event and then abruptly pauses itself. If a synchronous ActionScript event handler listens to this event and tries to replay the video using stream.play(), the stream would previously become incorrectly paused right after, because the EOF pause evaluation proceeded regardless of whether the stream was modified.

  • Extract reset_buffer() out from the asynchronous load_netstream closure in loader.rs and execute it synchronously inside NetStream::play().
  • Before executing the EOF auto-pause inside NetStream::tick(), we now evaluate Gc::ptr_eq against the original source pointer to verify that the backing buffer hasn't been reset during the status event dispatch.

An AVM2 test case is also included.

@kjarosh kjarosh added A-core Area: Core player, where no other category fits T-fix Type: Bug fix (in something that's supposed to work already) labels Apr 4, 2026
turicfr added 3 commits April 5, 2026 12:18
- Extract `reset_buffer()` out from the asynchronous `load_netstream`
closure in `loader.rs` and execute it synchronously inside `NetStream::play()`.
- Before executing the EOF auto-pause inside `NetStream::tick()`,
we now evaluate `Gc::ptr_eq` against the original `source` pointer
to verify that the backing buffer hasn't been reset during the status
event dispatch.
This ensures end-of-video event triggers can reliably resume playback
without hanging on the same tick.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core player, where no other category fits T-fix Type: Bug fix (in something that's supposed to work already)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants