Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
david_noorgames's avatar
david_noorgames
Honored Guest
9 years ago

[Gear-VR] Removing Stereo Layer Component from an Actor

Hello,
Here is how I use stereo layer to render high quality text using UMG 3D Widgets. The problem is, that it doesn't disappear when I destroy the actor containing the stereo layer. I can confirm this happens on Gear VR. Also if you wait about a minute, stereo layer will be garbage collected and not rendered anymore. Here's my Blueprint showing what I've done and also how I've tried to stop the rendering of stereo layer content. None of them worked.




Here's the code of destroying stereo layer component.



You may check that only Steam VR implements IStereoLayers, so I wonder how Gear VR layers should be destroyed. Looks like this functionality is missing. Please help.

7 Replies

Replies have been turned off for this discussion
  • @imperativity thank you for you answer.

    We have tried this on UE 4.15.1 and we have an update for 4.15.2. If we update the engine using Epic Luncher to 4.15.2 would it be the same version compared with the branch you mentioned above?


    Update: I can confirm that we have the same problem on 4.15.2 too. 

    Update 2: I've also noticed something suspicious inside IStereoRendering interface. Take a look at this method.


     
    FGearVR class implements this interface, but doesn't override this method. So we always get nullptr and do not pass that if statement on BeginDestroy() method inside StereoLayerComponent. Shouldn't we add this method in FGearVR class and use "return this" pointer in body, as it also inherits from IStereoLayers interface?

  • @imperativity, Thank you for your response. I think I've fixed my issue. Here's how.

    1. I've downloaded UE4 repo from github with 4.15.2 branch.
    2. In Engine\Plugins\Runtime\GearVR\Source\GearVR\Private\GearVR.h
    I have overrided the following method

    IStereoLayers* FGearVR::GetStereoLayers()
    {
        return this;
    }

    3. In Engine\Source\Runtime\Engine\Private\Components\StereoLayerComponent.cpp
    I have overrided this method

    void UStereoLayerComponent::DestroyComponent(bool bPromoteChildren /*= false*/)
    {
        Super::DestroyComponent(bPromoteChildren);

        IStereoLayers* StereoLayers;
        if (LayerId && GEngine->HMDDevice.IsValid() && (StereoLayers = GEngine->HMDDevice->GetStereoLayers()) != nullptr)
        {
            StereoLayers->DestroyLayer(LayerId);
            LayerId = 0;
        }
    }

    The last one is actually a copy-paste of BeginDestroy method of exact same class.

    After rebuilding the engine and also rebuilding my game, everything worked. BUT, we should check if this doesn't generate another issue. Because I'm having trouble with another problem atm, and not sure if they're related with these changes.
  • @imperativity sorry for late response. I was having another issue, which wasn't actually related to the fix I've made. I couldn't use 2 stereo layer components simultaneously. Either app was crashing, or one of stereo layers did not render properly (always showing black screen and sometimes we can notice drawn widget in 1 frame on fps drop).
    I'll create a different thread for this issue.
    Actually these issues are critical for us, so we would like to get informed about how they are tracked from your side. Thank you.
  • Anonymous's avatar
    Anonymous
    This is still happening to me in the latest Oculus 4.17.1 fork. I'm destroying my pawn with a StereoLayerComponent, and the UMG texture is still visible on-screen.
  • Anonymous's avatar
    Anonymous
    Solved for now by creating a new function DestroyLayer() that I can explicitly call in my actor's EndPlay() function.

    void UStereoLayerComponent::DestroyLayer()
    {
    IStereoLayers* StereoLayers;
    if (LayerId && GEngine->HMDDevice.IsValid() && (StereoLayers = GEngine->HMDDevice->GetStereoLayers()) != nullptr)
    {
    StereoLayers->DestroyLayer(LayerId);
    LayerId = 0;
    }
    }

    void UStereoLayerComponent::BeginDestroy()
    {
    Super::BeginDestroy();

    DestroyLayer();
    }

  • Anonymous's avatar
    Anonymous
    Well, that solved it for the Oculus on PC. But this crashes on the GearVR.


  • Anonymous's avatar
    Anonymous
    So I just set the visibility of the stereolayer and the hud components to false before destroying the pawn. And instead of calling Destroy(), I set the LifeSpan to 1.0f. That seemed to fix everything.