Skip to content

fix(avplayer): close safely from event callbacks - #5944

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Ondra97:codex/fix-avplayer-callback-close
Oct 16, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Ondra97:codex/fix-avplayer-callback-close

Conversation

@Ondra97

@Ondra97 Ondra97 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

What

Closing an AvPlayer from its event callback tried to join the controller thread that was running that callback. std::thread::join throws for a self-join, terminating the process during destruction.

When the controller closes its own player, detach that thread and retain a closure marker independently of the player. After the callback returns, the loop reads that marker and exits before accessing the destroyed player's locks or event queue. Closure from another thread still joins the controller normally.

The regression closes from the ready callback and the end-of-playback stop callback, creates a replacement player inside each callback, and checks that media allocations are released. It reuses the existing generated movie fixture and runs separately from the playback suite.

Tested

Windows 11 Pro 10.0.26300, supported WinLibs GCC 15.2.0, Release, main e34c47921.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source; none added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes, Codex

Full platform runtime CI requires a write-access collaborator to dispatch it under repository policy.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 5995 core/libs/prx/libSceAvPlayer/CMakeLists.txt L13, L18-19

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1601 core/libs/tests/GuestAvPlayer.cpp
PR 6044 core/libs/prx/libSceAvPlayer/CMakeLists.txt
core/libs/tests/GuestAvPlayer.cpp

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux run (Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests), head 5474b7756 merged onto main 44df21632.

  • Builds; guest_avplayer and the new guest_avplayer_callback_close pass.
  • With AvPlayer.hpp/Player.cpp from main: guest_avplayer_callback_close aborts with std::system_error / Resource deadlock avoided (glibc's EDEADLK for the self-join), the Linux counterpart of the Windows failure in the description. guest_avplayer still passes.

Non-GPU suite (ctest -E "^agc"): same result as main; only file_writer_binary and file_writer_text fail, and they fail on main too on this machine (Ubuntu 26.04 coreutils).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@adriadam10 adriadam10 self-assigned this Oct 16, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on Linux: build and ctest of AvPlayer/libs (34 tests) pass; with AvPlayer.hpp/Player.cpp reverted, guest_avplayer_callback_close fails, so it exercises the fix. The detached controller only touches the shared closed flag after the callback returns, and the flag outlives the player via the lambda capture. Matches jotitadev's Linux run. Merging.

@adriadam10
adriadam10 merged commit e576db7 into boykopovar:main Oct 16, 2026
9 checks passed
@Ondra97
Ondra97 deleted the codex/fix-avplayer-callback-close branch October 17, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants