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 calling GetCurrentProgramScene while current scene is unset #10532

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

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/PMfi7dChtUXVdAtX

OBS Studio Crash Log URL

https://obsproject.com/logs/EIFgTM87W2xlW3Fz

Expected Behavior

API should be returning a non-fatal error, and no settings corruption should occur.

Current Behavior

When calling GetCurrentProgramScene via the Websocket API while current scene is unset, a fatal crash occurs.
Then further crashes occur on OBS startup until the %APPDATA%/basic settings directory is deleted.

Steps to Reproduce

  1. Remove All Scenes via the Websocket API (GetSceneList -> RemoveScene)
  2. Request Current Scene via the API (GetCurrentProgramScene)

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 = ""
)

func main() {
	client, err := goobs.New(ServerURI, goobs.WithPassword(ServerPassword))
	if err != nil {
		panic(err)
	}

	err = RemoveAllScenes(client)
	if err != nil {
		panic(err)
	}

	_ = RequestCurrentScene(client)
	fmt.Printf("Crash should have occured post-request")
	return
}

func RequestCurrentScene(client *goobs.Client) error {
	_, err := client.Scenes.GetCurrentProgramScene(&scenes.GetCurrentProgramSceneParams{})
	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 ( #10533 ). I'm mentioning it as they may share a common underlying cause.

@tt2468
Copy link
Member

tt2468 commented Apr 14, 2024

If you add a 500ms pause after each iteration of the loop in RemoveAllScenes, does the crash go away? I think this may be a bug related to failure of a check to enforce there being at least one scene in the current collection. My guess is that the check iterates the full scene list, but does not exclude scenes which are "removed" but not destroyed yet, and the removed scenes are still being counted in the check.

@timmaclean
Copy link
Author

If you add a 500ms pause after each iteration of the loop in RemoveAllScenes, does the crash go away? I think this may be a bug related to failure of a check to enforce there being at least one scene in the current collection. My guess is that the check iterates the full scene list, but does not exclude scenes which are "removed" but not destroyed yet, and the removed scenes are still being counted in the check.

I tested with adding both a 500ms and 5000ms delay to all three calls (GetSceneList, RemoveScene, GetCurrentProgramScene), and the bug still occurred in both cases.

However, it did prevent the bug in #10533 from occurring, which would suggest that the two issues I reported may not actually be caused by the same underling issue/bug.

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