VideoCommon: update CustomAsset's load time to be before the load occurs (this prevents issues where the load time might be incorrectly inflated by long load operations)

Co-authored-by: Jordan Woyak <jordan.woyak@gmail.com>
This commit is contained in:
iwubcode 2025-05-23 23:27:11 -05:00
parent d940d62cae
commit 3b83907b88

View File

@ -13,12 +13,17 @@ CustomAsset::CustomAsset(std::shared_ptr<CustomAssetLibrary> library,
std::size_t CustomAsset::Load()
{
// The load time needs to come from before the data is actually read.
// Using a time point from after the read marks the asset as more up-to-date than it actually is,
// and has potential to race (and not be updated) if a change happens immediately after load.
const auto load_time = ClockType::now();
const auto load_information = LoadImpl(m_asset_id);
if (load_information.m_bytes_loaded > 0)
{
std::lock_guard lk(m_info_lock);
m_bytes_loaded = load_information.m_bytes_loaded;
m_last_loaded_time = ClockType::now();
m_last_loaded_time = load_time;
return m_bytes_loaded;
}
return 0;