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

Websocket API crash and settings corruption when recreating active scene #10533

Open
timmaclean opened this issue Apr 14, 2024 · 3 comments
Open

Comments

@timmaclean
Copy link

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

  1. Create a new Scene via the Websocket API (CreateScene)
  2. Make the newly created scene the active scene via the API (SetCurrentProgramScene)
  3. Remove All Scenes via the Websocket API (GetSceneList -> RemoveScene)
  4. 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

@timmaclean
Copy link
Author

FYI, I have reported a separate but similar bug to this one ( #10532 ). I'm mentioning it as they may share a common underlying cause.

@timmaclean
Copy link
Author

A comment in the other bug report I submitted (#10532 (comment)) 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.

@Glitched
Copy link

Glitched commented May 17, 2024

Having a similar issue via the websocket API on MacOS

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