Jump to content

[NOTABUG] UpdateAsyncThread() and Texture.Load() Crash in 2.20


photo

Recommended Posts

Posted (edited)

In Unigine ver 2.20, using Texture.Load() inside an UpdateAsyncThread() function will inevitably hang the the engine and then crash to desktop.  Sometimes it will load once or twice without issue but usually there is a hard hang as soon as the code is run even once.  The code works fine in ver 2.19.1.  The code works fine when used in Update() and UpdateSyncThread().  Below is example C# code...

 

    [ParameterAsset (Filter = ".texture")]
    public AssetLink testTexture;


    void UpdateAsyncThread(){

                if (testTexture != null){
                    Texture newTexture = new Texture();
                      if ( newTexture.Load(testTexture.Path, 0) ){
                          Log.Message("Texture Loaded!\n");
                      }
                      newTexture = null;
                  }
        }
 

Edited by TanukiDigital
Posted

TanukiDigital

Crash is kinda expected in that case, because you are interacting with GPU-related objects: https://developer.unigine.com/en/docs/2.20/code/fundamentals/thread_safety/?rlang=cpp&autotranslate=en#gpu_objects

Maybe it was working in 2.19 with DX11 only? 

You can rewrite this code in 2.20 and use special GPU_STREAM thread:

AsyncQueue.RunAsync(AsyncQueue.ASYNC_THREAD.GPU_STREAM, () =>
{
	if (testTexture != null)
	{
		Texture newTexture = new Texture();
		if (newTexture.Load(testTexture.Path, 0))
		{
			Log.Message("Texture Loaded!\n");
		}
		newTexture = null;
	}
});

Please note that you can only load resources in this thread.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Thank you for the code and explanation, it's much appreciated.  And yes using AsyncQueue.ASYNC_THREAD is working well.

  • silent changed the title to [NOTABUG] UpdateAsyncThread() and Texture.Load() Crash in 2.20
×
×
  • Create New...