Converting an Image to Texture in a ForEach Reactive

hey there,

probably not a bug but rather something I’m doing wrong, hence the question label.

i’m using the uEye camera nuget which outputs the camera feed via an Observable<Image>. I needed to get that into Stride so I naively put a ForEach (Reactive) with an ImageToTexture inside, and then a HoldLatest (Approach 1 in the screenshot below).

This resulted in vvvv hanging and eventually crashing when hovering tooltips or just scrolling in the IDE. I eventually managed to fix it by using the Approach 2, holding the latest image first and then converting to Texture.

image

I was just wandering what could have caused those crashes in the first place, is it a pattern that should be avoided? I was suspecting the camera’s framerate being too high, but it’s only 30 FPS actually.

According to Windows logs, the faulting dll when the crash occurs is nvwgf2umx.dll.

Thanks in advance!

I guess the observable is “in background” and ImageToTexture doesn’t like that.

Thanks for the pointer! Yes, assumed something like that but I would have expected it not to work at all if that was the case. What I experienced was it working for a bunch of frames, and then hanging/crashing.

Not sure but could be that two (or more) threads are accessing the same memory location. Since there is no sync / lock (I guess) this can work in some cases but doesn’t necessarily. When one thread tries to read while the other writes it goes boom.

1 Like

I think to “make a texture” you need to have rendering context, you can’t just build texture the texture is an image uploaded to GPU, so prolly imagetToTexture node is trying to find context, and fails… however i would bid on to that this is legit…

Yes, might be the case that the observable runs async in the camera thread… Should be possible though. Maybe have a look how it’s done in NDI?

1 Like

Indeed we’re currently developing such nodes in the NDI package for both Stride and Skia. Once they’re ready they will be moved to the respective core libraries. Should happen soonish.

5 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.