Clearing a stereo layer on destroy

I’m having some issues working with stereo layers, specifically destroying them. I have a simple actor with a stereo layer component displaying a widget. If I destroy the actor the “residue” of the stereo layer remains. By residue I mean the last state of the texture it’s rendering stays stuck on screen. If I don’t destroy the actor and simply set the texture of the stereo layer to “empty” (nullptr), the layer does in fact clear. So I know it can be cleared but the act of destroying the actor seems to happen too fast to allow this action to occur. Am I missing something simple? Is there an easy way to clear the stereo layer without having to build in some delay or event driven mechanism?

This is likely an issue on the VR runtime side. At least the SteamVR OpenXR runtime will not clear stereo layers if you don’t render a frame after turning the layer off. This might violate the OpenXR spec and is likely not intended behavior.

More info here:

I was afraid of that response :slight_smile: . I did see that post and thought, this can’t still be a thing from circa 2016!?

FWIW to anyone else who might happen upon this post, emptying out the texture for the stereo layer (either SetTexture(nullptr) in cpp or SetTexture with nothing plugged in for bp), will clear the stereo layer. The problem, as @Rectus_SA pointed out, is that the stereo layer component needs an extra frame to actually clear itself. That means any attempt to do this during something like BeginDestroy() is not going to work. In my situation this component is apart of a custom menu actor so I just created a function “DestroyMenu”, which destroys the menu on a delay. Once called it calls SetTexture to empty the stereo layer then starts a timer which results in a call to Destroy which actually destroys the menu. The timer is currently set to 0.5 seconds but could probably go lower. Either way, it’s enough time to allow the stereo layer to clear without any noticeable delay from the UX perspective.

3 Likes

Thank you so much for this, couldn’t understand why it wasn’t getting cleared, using two delay nodes set to 0.0 before the destroy node did it for me, one wasn’t enough, not sure why as 0.0 = 1 frame.