fix(avplayer): close safely from event callbacks #5944
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5944"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-14T16:38:01Z.
What
Closing an AvPlayer from its event callback tried to join the controller thread that was running that callback.
std::thread::jointhrows 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.std::system_errorfrom self-joining in the player destructor. With the fix it passes three consecutive runs (2.44 s total); the final test dispatcher layout also passes (0.88 s).guest_avplayerplayback suite passes (4.16 s). Full default Windows build, conventions and whitespace checks pass.Checklist
main; no other open PR implements the same functionsFull platform runtime CI requires a write-access collaborator to dispatch it under repository policy.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:12:03Z.
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.
main)core/libs/prx/libSceAvPlayer/CMakeLists.txtL13, L18-19Some 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.
core/libs/tests/GuestAvPlayer.cppcore/libs/prx/libSceAvPlayer/CMakeLists.txtcore/libs/tests/GuestAvPlayer.cppImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T20:04:10Z.
Review: COMMENTED
Linux run (Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests), head
5474b7756merged ontomain44df21632.guest_avplayerand the newguest_avplayer_callback_closepass.AvPlayer.hpp/Player.cppfrommain:guest_avplayer_callback_closeaborts withstd::system_error/Resource deadlock avoided(glibc's EDEADLK for the self-join), the Linux counterpart of the Windows failure in the description.guest_avplayerstill passes.Non-GPU suite (
ctest -E "^agc"): same result asmain; onlyfile_writer_binaryandfile_writer_textfail, and they fail onmaintoo on this machine (Ubuntu 26.04 coreutils).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T18:53:32Z.
Checked on Linux: build and ctest of AvPlayer/libs (34 tests) pass; with
AvPlayer.hpp/Player.cppreverted,guest_avplayer_callback_closefails, 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.