exeldro / obs-replay-source

Replay source for OBS studio
GNU General Public License v2.0
138 stars 20 forks source link

OBS hangs on executing action Load via websockets #15

Open MateuszSalski opened 4 years ago

MateuszSalski commented 4 years ago

I am using: OBS 25.0.06 on Ubuntu 18.4.

The issue happens only if a replay source has "Load Replay Switch Scene" set to parent scene of the replay source.

Scenario:

  1. Sources configuration:

    • there is a Media source on Scene 1
    • there is Replay source on Scene 2 with attached Media source in "Video source" field
    • "Load Replay Switch Scene" of a Replay source is set to Scene 2
  2. When sending: { "request-type":"SetSourceSettings", "message-id": "LoadReplay", "sourceName": "Replay source", "sourceSettings": { "execute_action": "Load" } } OBS hangs.

Analysis This is because before calling replay_source_update the data->sources_mutex is locked. replay_source_update calls obs_frontend_set_current_scene which invokes new thread for TransitionToScene event and waits for it. TransitionToEvent calls obs_context_data_insert which also locks &obs->data.sources_mutex, what makes a deadlock. See: call_stacks.txt

Fix proposition I will prepare my proposition how this can be fixed in https://github.com/MateuszSalski/obs-replay-source

It will be change in replay-source.c:

static void *replay_thread(void *data)
{
    struct replay_source *context = data;
    replay_hotkey(context, 0, NULL, true);
    return NULL;
}

static void replay_source_update(void *data, obs_data_t *settings)
{
    struct replay_source *context = data;
    const char *execute_action =
        obs_data_get_string(settings, SETTING_EXECUTE_ACTION);
    if (execute_action && strlen(execute_action)) {
        if (strcmp(execute_action, "Load") == 0) {
            pthread_t thread;
            pthread_create(&thread, NULL, replay_thread, context);
        } else if (strcmp(execute_action, "Next") == 0) {
exeldro commented 4 years ago

Now calling obs_frontend_set_current_scene always from a new thread. Can you test if that fixes it for you?

MateuszSalski commented 4 years ago

Sorry for late response. For sure OBS does not hangs now. Thanks. Unfortunately it looks that replay is not played, but maybe I configured something in a wrong way. I will check it and let you now.