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

UI: Keep weak stream output ref in status bar #10680

Merged
merged 1 commit into from
May 17, 2024

Conversation

RytoEX
Copy link
Member

@RytoEX RytoEX commented May 15, 2024

Description

The status bar doesn't currently own its references to outputs, which can be a problem if streaming outputs are released soon after stream stop. The Multitrack Video output does exactly that, so the status bar will sometimes try to access an invalid pointer for updating its stats. Keeping a weak reference around and upgrading it to collect stats, similar to how the stats window behaves.

Motivation and Context

Picked from #10633. Want to pull some commits out of that PR to make that PR smaller.

How Has This Been Tested?

This has been tested in the Twitch Enhanced Broadcasting beta.

Types of changes

  • Tweak (non-breaking change to improve existing functionality)
  • Code cleanup (non-breaking change which makes code smaller or more readable)

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.

@RytoEX RytoEX added Enhancement Improvement to existing functionality Code Cleanup Non-breaking change which makes code smaller or more readable labels May 15, 2024
@RytoEX RytoEX added this to the OBS Studio (Next Version) milestone May 15, 2024
@RytoEX RytoEX requested review from derrod and gxalpha May 15, 2024 22:23
@RytoEX RytoEX self-assigned this May 15, 2024
@RytoEX
Copy link
Member Author

RytoEX commented May 15, 2024

If pulling commits out of #10633 isn't helpful, we can close this. I find it easier to review small PRs and had offered to start pulling commits out of that PR, so I wanted to start working towards that.

Copy link
Member

@gxalpha gxalpha left a comment

Choose a reason for hiding this comment

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

Seems sane. If we’re not holding a strong reference we should not access the pointer (and if we were holding one we should listen to the appropriate signals to release it).

That said, this same thing should probably be applied to recordOutput too (even if it’s not causing crashes right now). I’d even consider this in-scope for this PR seeing how similar it is.

UI/window-basic-status-bar.cpp Show resolved Hide resolved
@cg2121
Copy link
Contributor

cg2121 commented May 16, 2024

If you are doing this for the streaming output, you should also do the recording output.

@RytoEX
Copy link
Member Author

RytoEX commented May 16, 2024

Regarding the recording output, while I initially had the same thought, the original commit in #10633 only addresses streaming output. I don't want to expand scope too much. I just want to trim down that PR. I can make a follow-up PR for recording output later.

@RytoEX RytoEX force-pushed the keep-weak-output-ref-status-bar branch from d93a2fa to 835b746 Compare May 16, 2024 18:58
The status bar doesn't currently own its references to outputs, which
can be a problem if streaming outputs are released soon after stream
stop. The Multitrack Video output does exactly that, so the status bar
will sometimes try to access an invalid pointer for updating its stats.
Keeping a weak reference around and upgrading it to collect stats,
similar to how the stats window behaves.
@RytoEX RytoEX force-pushed the keep-weak-output-ref-status-bar branch from 835b746 to 8d6d7e2 Compare May 17, 2024 17:26
@RytoEX RytoEX merged commit a18305d into obsproject:master May 17, 2024
15 checks passed
@RytoEX RytoEX deleted the keep-weak-output-ref-status-bar branch May 17, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup Non-breaking change which makes code smaller or more readable Enhancement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants