Skip to content

Websocket API crash and settings corruption when calling GetCurrentProgramScene while current scene is unset #10532

Open

Description

@timmaclean

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

Activity

  1. timmaclean commented on Apr 14, 2024

    @timmaclean
    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.

  2. tt2468 commented on Apr 14, 2024

    @tt2468
    Member

    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.

  3. timmaclean commented on Apr 15, 2024

    @timmaclean
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions