Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Apps using Windows Presentation Foundation (WPF) get a semi-random class name for each time window that is created (concretely, WPF generates a random GUID, that differs across closing and reoping windows and differs across app restarts). This means that is the window class is basically never stable for such apps.
When a user sets "Winow Match Priority" in OBS to "Match title, otherwise find window of same type", it will never find a window of the same type, and despite the name, OBS will actually reject an identical title if the window class does not match.
This PR adds the WPF-specific prefix to the list of
generic_class_substrings, so that OBS ignores the class for such WPF windows and always goes only by title.Motivation and Context
My team maintains the app Hearthstone Deck Tracker, which is a companion app to the game Hearthstone. It works by rendering an overlay in a separate window, which streamers capture and overlay on their stream. I've previously made changes to OBS in support of it in #13590. It uses Windows Presentation Foundation (WPF) as it's GUI framework.
I've recently had a streamer reach out to my about OBS losing track of a capturable window whenever they restart my overlay. Concretely they encountered this issue in Streamlabs, but I could reproduce the issue myself in OBS. It is as follows: In a Window Capture, the Window Match Priority "Match title, otherwise find window of same type" scans for the window class. After investigating, I realized that WPF Windows are created with a semi-random Window class:
https://github.com/dotnet/wpf/blob/997187874fe5d89cc66f9fbba8ededf14c556a30/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs#L91
Specifically, they are of the shape
HwndWrapper[{appName};{threadName};{randomName}], where random name is a random GUID chosen each time the window is created. This means a windows class capture will never match across app restarts, as the class will have changed.This so far is not a problem yet. However,
window_ratingwithWINDOW_PRIORITY_CLASSactually goes by the window class first and only checks the title if it matches. This is appropriate for basically every over app, but in the WPF case here it bricks capturing these apps until the user reselects the app (which will memorize the temporary class again, until it's closed and reopened).Clearly WPF is doing something very unusual here, and we are already recommending to our users to explicitly switch to Window Title matching. However, as WPF is used by many apps, I'm hoping a fix in OBS can improve this for more users.
How Has This Been Tested?
I've compiled this branch locally and confirmed with HDT that with the commit, it indeed works when the match priority is set to title/type and I restart the app.
Types of changes
Checklist: