Skip to content
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

libobs: Fix wrong order for source->async_mutex #11688

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

walker-WSH
Copy link
Contributor

@walker-WSH walker-WSH commented Jan 1, 2025

Description

same with #11687
For basic logic in libobs, gs should be requested before async_mutex.
In async_tick, there is no mutex locked before, so here the logic is being async_mutex->gs.
If another thread happens to be requesting gs->async_mutex, nested locks may cause UI block

Motivation and Context

keep stable order for requesting mutex.

How Has This Been Tested?

add media source, try to switch media file with different resolution, ensure video is display normally

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@walker-WSH walker-WSH changed the title libobs: Fix wrong order for requesting source->async_mutex libobs: Fix wrong order for source->async_mutex Jan 1, 2025
@walker-WSH walker-WSH force-pushed the wsh_asyncMutexOrder branch from a188f90 to 863fc6c Compare January 1, 2025 02:17
@exeldro
Copy link
Contributor

exeldro commented Jan 1, 2025

Would it not be better to move set_async_texture_size outside of the async mutex like it is in deinterlace_update_async_video ?

@walker-WSH
Copy link
Contributor Author

walker-WSH commented Jan 2, 2025

hi @exeldro I checked deinterlace_update_async_video and find it has multi-threaded safety issue.

this functions is called from graphic thread, and it is accessing prev_async_frame outside of async_mutex.
However, prev_async_frame must be accessed in async mutex because its lifetime is managed inside this mutex.

it may be free from other thread, such as callback of media source.

from graphic thread
1735794379

eg: from decode thread of media source
1735808651

1735794315

@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants