xObsAsyncImageSource - Asynchronous image source

xObsAsyncImageSource - Asynchronous image source v1.0

YorVeX

Member
YorVeX submitted a new resource:

xObsAsyncImageSource - asynchronous image source - OBS plugin providing an image source that loads images asynchronously (causing a lot less lag)

xObsAsyncImageSource​

OBS plugin providing an image source that loads images asynchronously (causing a lot less lag on load).
View attachment 91805

Prerequisites​

  • OBS 29+ 64 bit
  • Currently only working on Windows (tested only on Windows 10, but Windows 11 should also work)

Comparison to original image source​

Less lag and dropped frames​

The original image source can cause short...

Read more about this resource...
 

YorVeX

Member
YorVeX updated xObsAsyncImageSource - Asynchronous image source with a new update entry:

Version 0.3

If loading fails the async image source will now keep on trying to load the image every second until it succeeds. This way if the file was locked during the last load attempt (e.g. happens when it is updated at the exact time the image source tries to read the file) it will be updated a second later (whereas the original image source would never recover from this until the image file is updated once more).

Read the rest of this update entry...
 

BobbyJones

New Member
Great plugin, but can you please change the icon being different than the normal image source? Otherwise can not see if a source is using the original obs image or if its your async one :) thx
 

YorVeX

Member
I already thought about this, but my options are rather limited. OBS doesn't allow creating custom icons (and it also wouldn't sense, since this would break themes support), so I can only choose from the existing ones:
1683846961618.png

That would mean either using an icon that was actually meant for a different source type, which would be pretty confusing (and also: which one? maybe color source would remotely fit) or using the default custom icon, putting the source in the range of all other non-specific custom sources:
1683847045531.png


The idea is that it's an image source that is really close to the original in functionality (and it even is from code perspective), meaning in most scenarios it will be a 1:1 replacement for it and then it totally makes sense to me that it also has the image source icon. I feel like if I change the icon now to make you and the half of users happy that want it to be visually distinguishable from the original image source it will make the other half of users complain that although it's an image source it doesn't look like an image source from its icon.

Therefore I'd like to propose 2 things:
  1. Check whether you really need to use the original image source at all - if you really have a use case where you need it, because the async image source doesn't satisfy this need, then I'd like to hear it, maybe it's something I can do about? And if you don't need it, well, then don't use it at all and then you know what type all of your image sources are.
  2. Make it distinguishable yourself by giving it a prefix in the name (something like "[A] My banner" for async or "[O] My screenshot" for original or by using the OBS feature to set a color (right click -> Set Color) on one of the source types.
What do you think?
 

BobbyJones

New Member
thx for the detailed response.
The main problem is that there is NO way to see in obs if the original or async element has been used. They just look the same.
At least on the property page, there should be some kind of info, so can be sure its either normal img or async.

If using drag and drop for example, it just adds an element - I guess it is the original one - but there is no way to check difference than scanning the layout file I guess.
 

BobbyJones

New Member
- Is there a way to put an animation when the picture changes? Maybe it can use the build in Show/Hide transition or at least a Fade to look more smooth
 

YorVeX

Member
The main problem is that there is NO way to see in obs if the original or async element has been used. They just look the same.
Outside of what I already suggested (e.g. setting a color for them or a name prefix) there is actually two ways, though I have to admit they're not obvious. One would be to click the plus sign to add a new source, select "Image (Async)", check "Add Existing" and then the list will show you which sources are async sources (or you do the same on the original image source). This will give you an overview at one glance.

Another one if you want to check it for a specific item just select it in the Sources list and check the area above the list on the right. The original image source will show the file path of the image there and a Browse button:
1684100839547.png


For the async image this area will be empty. This is actually something I didn't plan and only noticed now when looking for differences. One could see it as a missing feature, but now that I realized it can be used to quickly distinguish the two I think I'll just leave it that way.

Is there a way to put an animation when the picture changes? Maybe it can use the build in Show/Hide transition or at least a Fade to look more smooth
Unfortunately no. The main idea behind this image source was to stay as close as possible to the original (especially internally/technically) and really only add this one single difference that it's async so that it doesn't cause lags, and I don't think I will steer away from that idea.

If someone wants that they could script something that will hide the source, change the underlying file and then show the source again - combined with hide and show transitions configured for the source you can then have whatever animations you want and you still get the benefit that the async source doesn't cause lags when showing it again (unlike the original source). But such things are outside the scope of this source for me, sorry.
 

BobbyJones

New Member
Outside of what I already suggested (e.g. setting a color for them or a name prefix) there is actually two ways, though I have to admit they're not obvious. One would be to click the plus sign to add a new source, select "Image (Async)", check "Add Existing" and then the list will show you which sources are async sources (or you do the same on the original image source). This will give you an overview at one glance.

Another one if you want to check it for a specific item just select it in the Sources list and check the area above the list on the right. The original image source will show the file path of the image there and a Browse button:
View attachment 94130

For the async image this area will be empty. This is actually something I didn't plan and only noticed now when looking for differences. One could see it as a missing feature, but now that I realized it can be used to quickly distinguish the two I think I'll just leave it that way.


Unfortunately no. The main idea behind this image source was to stay as close as possible to the original (especially internally/technically) and really only add this one single difference that it's async so that it doesn't cause lags, and I don't think I will steer away from that idea.

If someone wants that they could script something that will hide the source, change the underlying file and then show the source again - combined with hide and show transitions configured for the source you can then have whatever animations you want and you still get the benefit that the async source doesn't cause lags when showing it again (unlike the original source). But such things are outside the scope of this source for me, sorry.
how about a small info text that this is a async source at this position ?
edit: oh ya the source toolbar is a hint for that, thx

I tried to use this with the "Directory watch media" plugins, which auto updates when there is a new image in an folder, but looks like it doesnt work anyways with this async image element, as it does not update at all.

Thx for the detailed response again!
 

Attachments

  • obs64_7bHdcZq8fM.png
    obs64_7bHdcZq8fM.png
    9.4 KB · Views: 25
Last edited:

YorVeX

Member
how about a small info text that this is a async source at this position ?
As long as I stick to the original options I can use its translations into 61 additional languages, any additional text will immediately look out of place for anything outside of English, because I am always lacking the 61 translations for it. That's also why in the main menu the item is not translated and will always say "Image (Async)" even when your Italian OBS would label the original source as "Immagine". I thought about just putting "(Async)" next to the original text, but then again not all languages would have such addition to the right side of the text, by grammar logic or because it's a right to left written language.

But the one thing I will do here is just put the text "(Async)" at the top of its options on a single line for all languages, then I also don't have to worry about having it right or left of something, so thanks for that idea.

I tried to use this with the "Directory watch media" plugins, which auto updates when there is a new image in an folder, but looks like it doesnt work anyways with this async image element, as it does not update at all.

That plugin explicitly looks for certain types of sources, detecting them by their internal unique IDs, e.g. looking for the ID "image_source" that the original image source has. I don't think I should steal that ID with my source, the documentation says it's a unique string ID after all.

The async image source has a different internal ID "xObsAsyncImageSource", so the Directory Watch Media plugin would have to be modified to additionally look for this ID in order to be able to be used with it.
 

YorVeX

Member
I asked about this specific section in the main window that displays a file path for the original image source and how I could show something there on the dev Discord channel, and the answer was:
1684169191753.png

So I guess this difference will stay and help to distinguish it from the original.
 

ZeroEnna

New Member
Does the plugin also update images asynchronously?
I'm currently facing the problem that I regularly overwrite an image with a more recent one, but it keeps blanking the image entirely with the standard OBS image renderer
 

YorVeX

Member
Does the plugin also update images asynchronously?
I'm currently facing the problem that I regularly overwrite an image with a more recent one, but it keeps blanking the image entirely with the standard OBS image renderer
Yes, and during async loading of an updated image it should still continue showing the old image until it finished, then replace it in one go with the new one to avoid any flickering.

What you describe sounds even worse than just flickering, you get a blank image instead? And then, does it recover after a while or stay blank until you manually reload a new file? Can you maybe show a recording of how it looks exactly?
 

ZeroEnna

New Member
Yes, and during async loading of an updated image it should still continue showing the old image until it finished, then replace it in one go with the new one to avoid any flickering.

What you describe sounds even worse than just flickering, you get a blank image instead? And then, does it recover after a while or stay blank until you manually reload a new file? Can you maybe show a recording of how it looks exactly?
Thanks for the answer, unfortunately, the plugin crashes OBS, so I have to maybe reinstall OBS completely first.
It does recover after a while. My own explanation is that OBS tries to read the file while it is writte, thus creating a conflict resulting in this behaviour.
 

YorVeX

Member
Thanks for the answer, unfortunately, the plugin crashes OBS, so I have to maybe reinstall OBS completely first.
It does recover after a while. My own explanation is that OBS tries to read the file while it is writte, thus creating a conflict resulting in this behaviour.
I'm confused, first it creates a blank image, now it crashes OBS?
To rule out interferences it would be good if you could test this separately in an otherwise empty scene collection with the latest OBS version. For any crashes that occur, restart OBS, upload a crash report and share it here:
1691145588537.png


Also having the log would be helpful:
1691145616002.png


The kind of conflict that OBS tries to read the file while it is being written is normal to happen from time to time, but normally it doesn't crash OBS. The standard image source would in this case just skip that update and try again on the next update, xObsAsyncImageSource instead will retry every second until it succeeds (and in the meantime show the old image). It really shouldn't crash from that or show a blank image.

To see which role the process that overwrites the file plays, can you just try to overwrite the file manually by copying a different image with the same name there and see if that works better or also causes problems?

After writing this plugin I have used a script that kept on overwriting the image file (alternating between two images) and even held a lock on it for an unnecessary long time for the sake of testing, and let it run for 6 hours or so. Even after this long time and hundreds of updates I didn't see any crashes and updating worked fine, so currently I cannot reproduce this issue here. That was only on Windows though, maybe there is an issue on Linux?
 

ZeroEnna

New Member
Sorry for the confusion :D

Not YOUR plugin is showing a blank image, but the DEFAULT OBS Image source. Whenever I update the image automatically, the DEFAULT image source completely blanks the image, as if it is unable to load the image.

That's why I asked how your plugin behaves.

HOWEVER; when I tried your plugin, my OBS was crashing after a few minutes, and it stopped after I uninstalled your Plugin.
What I believe, though, is that my entire OBS installation might be corrupt, so before I jump to any conclusions, I am going to completely reinstall OBS and try it again with your plugin. If it keeps crashing after a clean reinstall, I will send you the log files, but I doubt that it will happen again.
 

YorVeX

Member
Sorry for the confusion :D

Not YOUR plugin is showing a blank image, but the DEFAULT OBS Image source. Whenever I update the image automatically, the DEFAULT image source completely blanks the image, as if it is unable to load the image.

That's why I asked how your plugin behaves.

HOWEVER; when I tried your plugin, my OBS was crashing after a few minutes, and it stopped after I uninstalled your Plugin.
What I believe, though, is that my entire OBS installation might be corrupt, so before I jump to any conclusions, I am going to completely reinstall OBS and try it again with your plugin. If it keeps crashing after a clean reinstall, I will send you the log files, but I doubt that it will happen again.
Ah, thanks for clearing that up, now it makes more sense.

The default image plugin has a bug (or at least nor very good behavior) where if a single update fails because the file is locked (which can and will happen on concurrent file access at some point) it will completely skip that update and not recover from it by itself. Only the next update after that again will trigger the next attempt. There is a PR to improve this but so far it hasn't been merged into the main branch.

When creating the async image source I knew about this problem so I included an improvement where it will keep on retrying every second. A crash is not what I would expect there, especially given that I tested specifically this locking case quite thoroughly.

I agree that it should at least be ruled out that nothing is wrong with your OBS installation. Also the tool you are using to overwrite the file might play a role, that's why I asked to try with a simple file copy and compare this. In many programming languages programmers have to explicitly release locks on files after they finished writing to it, but it's not very rare that programmers forget this. It sounds a bit suspicious that it happens so consistently for you, like, already on the first overwrite. If the tool never releases the file lock this would actually make sense.

Last but not least, there are different levels of file locks (read, write, both, with and without exclusive access...), maybe there's a combination I didn't test so far which causes problems.

I will just wait for your further tests and logs if it keeps on occurring even after a fresh install.
 
Top