Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

error when switching scene collection, source not being released #139

Open
adjstreams opened this issue Nov 5, 2023 · 1 comment
Open

Comments

@adjstreams
Copy link

adjstreams commented Nov 5, 2023

I'm using Windows 11. OBS 29.1.3. Python 3.11

I have added the latest version of the script.

It's been working fine, but when I tried to switch scene collections, I get an error:

"There was a problem while changing scene collections and some sources could not be unloaded. This issue is typically caused by plugins that are not releasing resources properly. Please ensure that any plugins you are using are up to date.

OBS will not exit to prevent any potential data corruption."

According to the log, the source it couldn't unload was "Display Capture - Screen 1", the source that my script is pointing at. If I remove the script and restart, the problem stops occurring. It's only when the script is added that I get this issue.

Having added the script back in and selected a different source, the same thing happens but for the new source, e.g. a Window Capture source.

So I believe the script or its dependencies are not unloading the source correctly before OBS attempts to switch scene collection?

I suspect the same root cause is also responsible for the crash message I get when I shut down OBS, it's unable to release the source in time.

I've added a log message after this line:

obs.source_list_release(zoom.source_refs)
log("released sources?")

And looking at the logs I get this. So it looks like the line to source_list_release fails in my case.

22:28:47.150: [Python: zoom_and_follow_mouse.py] Run script_unload
22:28:47.150: [Python] source_list_release:1140: SWIG failed to convert python object to obs object: obs_source_t *
22:28:47.150: [Python: zoom_and_follow_mouse.py] released sources?
22:28:47.150: [obs-scripting]: Unloaded python script: zoom_and_follow_mouse.py

I then tried to modify the code to loop through release sources individually like this:

def script_unload():
    log("Run script_unload")

    # Get the source by name and release it
    source_name = zoom.source_name
    source = zoom.get_obs_source(source_name)
    if source is not None:
        # Release the crop filter, if it exists
        crop = obs.obs_source_get_filter_by_name(source, CROP_FILTER_NAME)
        if crop is not None:
            obs.obs_source_filter_remove(source, crop)
            obs.obs_source_release(crop)  # Release the crop filter
            log(f"Released crop filter from source: {source_name}")

        obs.obs_source_release(source)  # Release the source
        log(f"Released source: {source_name}")

    # If zoom.source_refs is a list of source names, release each source
    if isinstance(zoom.source_refs, list):
        for source_name in zoom.source_refs:
            source = obs.obs_get_source_by_name(source_name)
            if source is not None:
                obs.obs_source_release(source)
                log(f"Released source: {source_name}")

    # Unregister hotkeys
    obs.obs_hotkey_unregister(toggle_zoom)
    obs.obs_hotkey_unregister(toggle_follow)
    log("Finished running script_unload")

And I can see from the logs

01:22:17.175: [Python: zoom_and_follow_mouse.py] Run script_unload
01:22:17.175: [Python: zoom_and_follow_mouse.py] Released crop filter from source: Display Capture
01:22:17.175: [Python: zoom_and_follow_mouse.py] Released source: Display Capture
01:22:17.175: [Python: zoom_and_follow_mouse.py] Released source: Display Capture
01:22:17.175: [Python: zoom_and_follow_mouse.py] Finished running script_unload
01:22:22.175: [obs-scripting]: Unloaded python script: zoom_and_follow_mouse.py
01:22:22.175: [adv-ss] trying to reconnect to in 10 seconds.
01:22:22.175: [adv-ss] reset transition behaviour to adjust active transition type
01:22:22.200: Not all sources were cleared when clearing scene data:
01:22:22.200:
01:22:22.200: - Display Capture
01:22:22.200:

The double mention of "Released source: Display Capture" makes sense because I'm directly releasing the named source, and then releasing each entry in the reference list, however, it still errors, claiming that "Display Capture" hasn't actually been cleared.

I wonder if I have another plugin that is stopping this from being released, but I'm running out of ideas to debug.

@thelegendtubaguy
Copy link

This is the same as #124

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants