Jump to content

Unity URP MSAA causes crash on Focus 3


datgavin
 Share

Recommended Posts

 

Enabling any level of MSAA in my URP pipeline asset Quality settings results in a crash when running builds on the Focus 3.

I found a note about MSAA and URP in https://hub.vive.com/storage/docs/en-us/UnityXR/UnityXRKnownIssue.html; not sure if this refers to the same issue I'm experiencing.

 

Project configuration

  • Unity version: 2019.4.24 LTS
  • Using recommended player settings for Wave per "WaveXRPlayerSettingsConfigDialog"
  • VIVE packages:
    • Wave XR Plugin + Essence + Native v4.1.1-r.3.1
  • Unity packages:
    • XR Plugin Management v3.2.13
    • XR Legacy Input Helpers v2.1.4
    • Universal RP + Core RP Library v7.5.3 (also tried 7.6.0)
  • Other packages:
    • MRTK v2.7.2
    • Vuforia v9.7.4
    • Photon Unity Networking + Voice v2.24.1
  • Using Single Pass Render Mode in WaveXRSettings, all other settings are default

 

I am manually initializing the Wave XR Plugin using XRGeneralSettings.Instance.Manager.StartSubsystems(); this works fine when MSAA is disabled.

Attached is some potentially relevant ADB logcat. msaa_crash_logcat.txt

Link to comment
Share on other sites

Hi,

Can you try adjusting the WaveXRPlayerSettingsConfigDialog two different ways:

A) No AA on all quality settings
B) Consistent AA on all quality settings.

There is an issue with the latest wave sdk and switching AA settings which causes a crash.


There are also different issues with specific versions of the URP and corerp library which cause crashes with XR packages. I'm guessing that is not the issue, but for the sake of completeness it's worth bringing up.

There are other possibilities, and if the above doesn't work, I'd love to have a minimal project setup that reproduces this crash. 
 

Thanks,
Alex

Edit: Do you have "Initialize XR on Startup" unchecked in Project Settings->XRPluginManagment->android?

Link to comment
Share on other sites

It's been a little while since I've used the startsubystem syntax for some of this stuff, but I remember it requiring a bit of extra paranoia due to timing/threading issues.

 

Quote
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Management;

public class SampleInit : MonoBehaviour
{
    IEnumerator Start()
    {
        while (XRGeneralSettings.Instance == null )
        {
            Debug.Log($"Waiting on XRGeneralSettings.Instance frame {Time.frameCount}");
            yield return null;
        }
        while ( XRGeneralSettings.Instance.Manager == null)
        {
            Debug.Log($"Waiting on XRGeneralSettings.Instance.Manager frame {Time.frameCount}");
            yield return null;
        }
        yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
        
        while (!XRGeneralSettings.Instance.Manager.isInitializationComplete)
        {
            Debug.Log($"Waiting on XRGeneralSettings.Instance.Manager.isInitializationComplete frame {Time.frameCount}");
            yield return null;
        }
        Debug.Log($"about to call XRGeneralSettings.Instance.Manager.StartSubsystems frame {Time.frameCount}");
        XRGeneralSettings.Instance.Manager.StartSubsystems();
        Debug.Log($"done calling XRGeneralSettings.Instance.Manager.StartSubsystems  frame {Time.frameCount}");
    }

}

Seemed to work when I attached+ran it on a scene with a stock xr rig with 2019.4.30f1

I put up a version of it at https://github.com/hardcoded2/URP-Example for comparison

I pulled a copy with  2019.4.24f1 and it isn't loading a shader. I assume it's just bedtime 🙂

I'll look at it in the morning, but try 2019.4.30f1 or higher to start along with the above modified init

Link to comment
Share on other sites

Thanks for the quick response!

I'm using the same Universal Render Pipeline asset for all Quality levels in my Project Settings, so I assume that means all levels will use the same MSAA value as set in the pipeline asset. I also tried editing my ProjectSettings/QualitySettings.asset file in a plaintext editor so that all the "antiAliasing: x" serialized properties have the same value, but it looks like Unity is changing those settings back without me doing anything (specifically, the "Very Low" Quality level is always reset to antiAliasing: 0). 

I do have "Initialize XR on Startup" in my XR Plugin Management settings for Android unchecked; I added those extra waits you suggested to my manual XR plugin initialization coroutine but that didn't seem to change anything. No MSAA works fine on the Focus 3; enabling any amount of MSAA works in the Unity Editor but crashes on the device.

I'll work on reproducing this issue in a minimal project, but I probably won't be able to get to that until next week.

Thanks again.

Link to comment
Share on other sites

Here's a (Unity 2019.4.24) project that produces the crash when MSAA is enabled in URP asset settings: URP_AA_Crash.zip

I started getting the problem again in this project after I added MRTK; looks like there is some sort of timing concern between (manual) initialization of the Wave XR plugin, URP and MRTK. For anyone interested, the attached project includes some custom XR SDK device manager and controller classes for using the MRTK input system on Focus 3.

I was eventually able to find a workaround to use MSAA without crashing by disabling it when the app starts, then waiting until XR initializes before re-enabling MSAA.

This is the component class I'm using to do this:

Quote
using System.Collections;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.XR.Management;

// execute before MRTK and XRPluginManualInit
[DefaultExecutionOrder(-102)]
public class MSAAFix : MonoBehaviour
{
    public UniversalRenderPipelineAsset urpAsset;
    public int msaaSamplesOverride;

#if UNITY_EDITOR
    private int msaaSamplesRestore;
#endif

    private void Start()
    {
        // store URP asset's initial MSAA setting
        if (msaaSamplesOverride < 1)
            msaaSamplesOverride = urpAsset.msaaSampleCount;

#if UNITY_EDITOR
        msaaSamplesRestore = urpAsset.msaaSampleCount;
#endif

        // disable MSAA
        urpAsset.msaaSampleCount = 1;

        if (msaaSamplesOverride > 1)
            StartCoroutine(ReEnableAA());
    }

    IEnumerator ReEnableAA()
    {
        // wait for XR initialization to complete
        while (XRGeneralSettings.Instance == null)
            yield return null;

        if (!XRGeneralSettings.Instance.InitManagerOnStart)
        {
            while (XRGeneralSettings.Instance.Manager == null || !XRGeneralSettings.Instance.Manager.isInitializationComplete)
                yield return null;

            while (XRGeneralSettings.Instance.Manager.activeLoader == null)
                yield return null;
        }

        yield return null;

        // restore MSAA
        print("Setting MSAA to " + msaaSamplesOverride + "x");
        urpAsset.msaaSampleCount = msaaSamplesOverride;
    }


#if UNITY_EDITOR
    private void OnDestroy()
    {
        StopAllCoroutines();
        urpAsset.msaaSampleCount = msaaSamplesRestore;
    }
#endif
}

I'm satisfied with this solution and willing to consider the issue resolved.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...