Fix deadlock in asset thumbnails rendering queue when texture streaming fails
#2057
This commit is contained in:
@@ -35,6 +35,11 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
/// The finalized state.
|
||||
/// </summary>
|
||||
Disposed,
|
||||
|
||||
/// <summary>
|
||||
/// The request has failed (eg. asset cannot be loaded).
|
||||
/// </summary>
|
||||
Failed,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -78,6 +83,14 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
Proxy = proxy;
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
if (State == States.Prepared && (!Asset || Asset.LastLoadFailed))
|
||||
{
|
||||
State = States.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepares this request.
|
||||
/// </summary>
|
||||
@@ -85,11 +98,8 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
{
|
||||
if (State != States.Created)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
// Prepare
|
||||
Asset = FlaxEngine.Content.LoadAsync(Item.Path);
|
||||
Proxy.OnThumbnailDrawPrepare(this);
|
||||
|
||||
State = States.Prepared;
|
||||
}
|
||||
|
||||
@@ -101,9 +111,7 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
{
|
||||
if (State != States.Prepared)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
Item.Thumbnail = icon;
|
||||
|
||||
State = States.Rendered;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
|
||||
internal static bool HasMinimumQuality(TextureBase asset)
|
||||
{
|
||||
if (asset.HasStreamingError)
|
||||
return true; // Don't block thumbnails queue when texture fails to stream in (eg. unsupported format)
|
||||
var mipLevels = asset.MipLevels;
|
||||
var minMipLevels = Mathf.Min(mipLevels, 7);
|
||||
return asset.IsLoaded && asset.ResidentMipLevels >= Mathf.Max(minMipLevels, (int)(mipLevels * MinimumRequiredResourcesQuality));
|
||||
@@ -499,6 +501,7 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
var request = _requests[i];
|
||||
try
|
||||
{
|
||||
request.Update();
|
||||
if (request.IsReady)
|
||||
{
|
||||
isAnyReady = true;
|
||||
@@ -507,6 +510,10 @@ namespace FlaxEditor.Content.Thumbnails
|
||||
{
|
||||
request.Prepare();
|
||||
}
|
||||
else if (request.State == ThumbnailRequest.States.Failed)
|
||||
{
|
||||
_requests.RemoveAt(i--);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user