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

OBS hangs for several seconds after every single action inside of OBS #2

Open
mattcalabrese opened this issue Mar 24, 2022 · 1 comment

Comments

@mattcalabrese
Copy link

After installing ghub, OBS started lagging for 5 to 10 seconds after every single action that I perform inside of obs (things as simple as clicking on a different scene!). I have a 5950x with 128 gigs of ram, so this should really not be happening. I was able to reduce the problem down to this plugin (which, notably, seems to secretly install itself and there is no option in ghub to turn it off). Deleting the plugin fixes the issue so that there is absolutely no hang after any action, however ghub keeps silently reinstalling the plugin every time i delete it.

The performance issue seems to be caused by logi::applets::obs_plugin::helper_populate_collections. This is executed after most actions in OBS, and inside of the function it is redundantly accessing a nested std::map for every single source in every scene. Also, for each of those redundant lookups, multiple new and redundant std::strings are created.

There are a few easy ways to fix this without changing the structure of the plugin too much at a high level:

  1. Don't perform redundant lookups into the maps. Each operator[] call has to do a lookup through the entire map. If you need to index, it's best to do it exactly once per element and hold onto a reference to that element.

  2. Use a container other than std::map. If using a different standard container, std::unordered_map will be the easiest drop-in replacement and has better complexity for the operations being used.

  3. Don't create redundant std::string objects. Modern c++ standards allow for heterogeneous lookup into associative containers. This means that you do not have to create even a single std::string just indexing into an associative container.

I cannot be the only person to have been impacted by this, but I'm sure those who are impacted just assume that it is OBS itself that is the culprit and have not looked into it more deeply. The problem also gets more pronounced as the amount of sources increases. I have a [relatively] large number of sources in OBS, but nothing too extreme and I am sure that there are people with more. Anyone who has a moderate amount of sources and has ghub installed will experience this issue.

@CookingWithCale
Copy link

CookingWithCale commented May 8, 2024

I'm also having this problem. I'm tired of having to delete the plugin every time I boot my computer. G Hub needs to stop auto-reinstalling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants