Skip to content

frontend: Fix OAuth and dock state save corruption#13445

Open
PatTheMav wants to merge 1 commit into
obsproject:masterfrom
PatTheMav:save-corruption-fix
Open

frontend: Fix OAuth and dock state save corruption#13445
PatTheMav wants to merge 1 commit into
obsproject:masterfrom
PatTheMav:save-corruption-fix

Conversation

@PatTheMav
Copy link
Copy Markdown
Member

Description

Wraps functionality that saves OAuth data and browser dock state in a std::call_once block to ensure that regardless of how often OBSBasic::saveAll is called the data is only saved once and partial data does not overwrite the config values on consecutive calls (at which the state of the OAuth data and browser docks cannot be considered "complete" anymore).

Motivation and Context

When the app is quit on macOS, the underlying process is either triggered by an application-level "Quit" event or by a main window "close" event.

If the application-level "Quit" event is the trigger, OBSBasic::saveAll is called twice:

  1. By Qt's session manager (via OBSApp::commitData).
  2. By the main window's close event handled by OBSBasic::closeWindow.

However if the main window is closed first (and is the first to call "saveAll") the underlying OAuth data object is destroyed after the data has been saved. When the second "saveAll" call takes place, it encounters a nullptr for the auth object, which makes Auth::Save effectively remove any OAuth configuration from the settings file (undoing prior work).

At the other end, if the application quits first, some dock windows might have been explicitly closed by Qt before the main window is closed and thus the second call to saveAll will overwrite valid browser dock state data with incomplete data (any dock that has been closed by Qt before will not be present in that data).

Wrapping the code responsible for saving OAuth and browser dock state data in a std::call_once block should ensure that this data is only written once and by whoever gets to call saveAll first (at which point state data is still considered "complete").

Fixes #13440
Fixes #13099

How Has This Been Tested?

Tested on macOS 26 by having a YouTube service connection active and several browser and non-browser docks detached and placed at specific positions on screen.

Terminated OBS by menu item, dock menu, and by closing the main window, confirmed that both service connection and dock state and position were correctly restored when OBS was relaunched.

Types of changes

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

Checklist:

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

When the app is quit on macOS, the underlying process is either
triggered by an application-level "Quit" event or by a main window
"close" event.

If the application-level "Quit" event is the trigger, OBSBasic::saveAll
is called twice: First by Qt's session manager (via OBSApp::commitData)
and another time by the main window's close event handled by
OBSBasic::closeWindow.

However if the main window is closed first (and is the first to call
"saveAll") the underlying OAuth data object is destroyed after the data
has been saved. When the second "saveAll" call takes place, it
encounters a "nullptr" for the auth object, which makes "Auth::Save"
effectively remove any OAuth configuration from the settings file
(undoing prior work).

At the other end, if the application quits first, some dock windows
might have been explicitly closed by Qt before the main window is closed
and thus the second call to "saveAll" will overwrite valid browser dock
state data with incomplete data (any dock that has been closed by Qt
before will not be present in that data).

Wrapping the code responsible for saving OAuth and browser dock state
data in a "std::call_once" block should ensure that this data is only
written once and by whoever gets to call "saveAll" first (at which point
state data is still considered "complete").
@PatTheMav PatTheMav added kind/bug Categorizes issue or PR as related to a bug. platform/macos Categorizes issue or PR as affecting macOS specifically labels May 19, 2026
@Warchamp7 Warchamp7 self-requested a review May 19, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. platform/macos Categorizes issue or PR as affecting macOS specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YouTube Account Disconnects on Startup Restarting OBS resets the display of custom browser docks.

1 participant