Websocket API crash and settings corruption when recreating active scene
Operating System Info
Windows 11
Other OS
No response
OBS Studio Version
30.1.2
OBS Studio Version (Other)
No response
OBS Studio Log URL
https://obsproject.com/logs/FHZeBkwviLAZ7XnQ
OBS Studio Crash Log URL
https://obsproject.com/logs/cGfkBclwG4JMzIeP
Expected Behavior
No crash or settings corruption should occur.
Current Behavior
When calling CreateScene via the Websocket API using the name of the previously active scene that has just been deleted, a fatal crash occurs. Then further crashes occur on OBS startup until the %APPDATA%/basic settings directory is deleted.
Steps to Reproduce
- Create a new Scene via the Websocket API (CreateScene)
- Make the newly created scene the active scene via the API (SetCurrentProgramScene)
- Remove All Scenes via the Websocket API (GetSceneList -> RemoveScene)
- Create a new scene using the same name used in (1) via the Websocket API (CreateScene)
I've got a minimal golang program that reporduces this issue below, hopefully that is all you need to reproduce this.
package main
import (
"fmt"
"github.com/andreykaipov/goobs"
"github.com/andreykaipov/goobs/api/requests/scenes"
)
const (
ServerURI = "127.0.0.1:4455"
ServerPassword = ""
SceneName = "TestScene"
)
func main() {
client, err := goobs.New(ServerURI, goobs.WithPassword(ServerPassword))
if err != nil {
panic(err)
}
err = CreateScene(client, SceneName)
if err != nil {
panic(err)
}
err = SwitchToScene(client, SceneName)
if err != nil {
panic(err)
}
err = RemoveAllScenes(client)
if err != nil {
panic(err)
}
_ = CreateScene(client, SceneName)
fmt.Printf("Crash should have occured post-request")
return
}
func CreateScene(client *goobs.Client, sceneName string) error {
_, err := client.Scenes.CreateScene(&scenes.CreateSceneParams{
SceneName: &sceneName,
})
return err
}
func SwitchToScene(client *goobs.Client, sceneName string) error {
_, err := client.Scenes.SetCurrentProgramScene(&scenes.SetCurrentProgramSceneParams{
SceneName: &sceneName,
})
return err
}
func RemoveAllScenes(client *goobs.Client) error {
sceneList, err := client.Scenes.GetSceneList()
if err != nil {
return err
}
for _, scene := range sceneList.Scenes {
_, err := client.Scenes.RemoveScene(&scenes.RemoveSceneParams{
SceneName: &scene.SceneName,
})
if err != nil {
return err
}
}
return nil
}
Anything else we should know?
No response
FYI, I have reported a separate but similar bug to this one ( https://github.com/obsproject/obs-studio/issues/10532 ). I'm mentioning it as they may share a common underlying cause.
A comment in the other bug report I submitted (https://github.com/obsproject/obs-studio/issues/10532#issuecomment-2054085464) suggested adding a delay after calling RemoveScene, to determine if a race condition was occurring.
While it had no impact in that issue, when applying a 500ms delay to the call in this issue it resulted in the crash no longer occurring, and the final CreateScene call works as expected.
Having a similar issue via the websocket API on MacOS