Error: 'texture didn't exist or already freed' when exiting Play Mode with XR Interaction Toolkit

Hi everyone,

I’m encountering an issue related to the XR Interaction Toolkit when I run and then exit Play Mode. Specifically, I get the following error in the console:

texture didn’t exist or already freed
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

My Notebook:
AMD Ryzen 9 6900HX
32 GB RAM
AMD Radeon RX 6850M XT

Meta Quest 3

The issue occurs when:

  1. I press Play to run the game.
  2. Everything works fine while the game is running.
  3. When I stop Play Mode (exit the game), the error appears.

What I’ve Tried:

  • I’ve ensured that all my XR-related packages (XR Interaction Toolkit, OpenXR, etc.) are up to date.
  • I switched to the latest Unity version LTS Version 2022.3.46f1.
  • The error also occurs in the default XR Interaction Toolkit DemoScene, so it’s not something specific to my project.

I’ve also tried manually stopping the XR subsystems in OnApplicationQuit() and when exiting Play Mode, but the issue still persists.

Here’s a relevant snippet of my debugging code for tracking the destruction of XR subsystems:

protected void DestroySubsystem<T>() where T : class, ISubsystem
{
T subsystem = GetLoadedSubsystem<T>();

// Debug output before destruction
if (subsystem != null)
{
    Debug.Log("Subsystem before destruction: " + subsystem.GetType().Name);
}
else
{
    Debug.Log("Subsystem is already null or not present.");
}

if (subsystem != null)
{
    var subsystemType = typeof(T);
    if (m_SubsystemInstanceMap.ContainsKey(subsystemType))
    {
        m_SubsystemInstanceMap.Remove(subsystemType);
    }
    
    subsystem.Destroy();
    
    // Debug output after destruction
    Debug.Log("Subsystem after destruction: " + (GetLoadedSubsystem<T>() == null ? "Successfully destroyed" : "Still active"));
}

}

The subsystems seem to be destroyed correctly (as indicated by my log messages), but the “texture didn’t exist or already freed” error keeps appearing after the XR subsystems (like XRInputSubsystem and XRDisplaySubsystem) are destroyed.

My Question:

Has anyone encountered a similar issue with textures being released or attempted to be accessed after XR subsystems are destroyed? Are there any recommended ways to ensure that textures are properly handled when exiting Play Mode, especially in XR setups?

I appreciate any advice or potential solutions you might have!

Thanks in advance for your help!

Best Regards
Jan

Update 09/14/2024

I have now tested the issue on another laptop (Razer Blade 16, Geforce RTX 4080 - Intel Core i9-13950HX), and the exact same problem occurs. I also manually updated my XR Interaction Toolkit to version 3 (3.0.5), but the error persists.

2 Likes

Same problem on Quest 3, Unity 2022.3.45f1.
Intel i7
16GB RAM
Nvidia GTX 1660

Running DemoScene from XR Interaction Toolkit Starter Assets

Best regards

Unity 2022.3.47f1
Intel i7
NVIDIA GTX 1080

I’m also having the Error, with only “OpenXR Plugin”, “XR Plugin Management”, and “XR Hands” and their dependencies installed (so no XR Interaction Toolkit)

Unity 6000.0.21.f1
Intel i7
NVIDIA GTX 1060

Also getting the “Texture didn’t exist or already freed” error.

Same here. I doubt machine matters.

XR Hands, XR interaction toolkit, OpenXR, gotta be one of those.

Hi there,
Thank you for reporting this.

This is a known Engine-related issue. The engine works as expected, and the issue is harmless. That message is only related to our internal integration tests. This problem will be resolved in the foreseeable future. Sorry for the inconvenience.