Fix Twitch-Specific Filters Not Being Applied #4529
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
#4107 previously tried to fix this issue, but was later reverted (#4111), because having a filter like
channel.live
in a live channel would "freeze" (deadlock) the app (#4110). This PR fixes this deadlock and applies the fix by #4107.The deadlock was caused, because the lock-guard in
TwitchChannel::setLive
was kept alive for too long. Specifically,setLive
adds a message which then gets to the filter which tries to accessstreamStatus_
, which is locked insetLive
(deadlock).I prevented this by reducing the critical-section where the guard is kept alive.
I also noticed that
TwitchChanne::isLive
calledaccess
overaccessConst
which lead me down a shallow rabbit-hole:UniqueAccess
forstreamStatus_
isn't actually needed (probably similar for others as well). If you addassertInGuiThread
before every access, you'll see that the app works fine. This is because (1) helix-calls aren't concurrent, (2) command-variables are substituted concurrently, (3) commands aren't executed concurrently, and (4) filters aren't checked concurrently.TwitchChannel::twitchBadge
,TwitchChannel::cheerEmote
,TwitchBadges::badge
,DebugCount::getDebugText
, andChannelChatters::colorsSize
useUniqueAccess::access
overUniqueAccess::accessConst
, even though they don't modify the underlying data.UniqueAccess<T> &operator=(const T &element)
andUniqueAccess<T> &operator=(T &&element)
are unsound. They should lock the mutex before modifying the data. OnlyUniqueAccess<T> &operator=(const T &element)
is used here.Fixes #4112.