Cherry Pick: [LYN-7463] Fix insert streaming request failure (#5604) (#5622)

* Fix race condition where asset would finish loading and another request would start before the streamer request could be cleared

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Re-enable disabled test which was failing for the same reason.

Fix test timeout which was way too long.
Reduce test iterations to keep test time safely under 5 seconds.

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Instead of using a mutex, re-order the statements to remove the streamer request first

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
(cherry picked from commit 0cea59d669)
Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
This commit is contained in:
amzn-mike
2021-11-15 16:14:43 -06:00
committed by GitHub
parent 82c83b2c5a
commit 8b7e538dd3
2 changed files with 8 additions and 4 deletions
@@ -1677,9 +1677,13 @@ namespace AZ
// they will trigger a ReleaseAsset call sometime after the AssetManager has begun to shut down, which can lead to
// race conditions.
// Make sure the streamer request is removed first before the asset is released
// If the asset is released first it could lead to a race condition where another thread starts loading the asset
// again and attempts to add a new streamer request with the same ID before the old one has been removed, causing
// that load request to fail
RemoveActiveStreamerRequest(assetId);
weakAsset = {};
loadingAsset.Reset();
RemoveActiveStreamerRequest(assetId);
};
auto&& [deadline, priority] = GetEffectiveDeadlineAndPriority(*handler, asset.GetType(), loadParams);