pull/297/head
hevinci 2024-05-10 10:57:06 +08:00
parent 05e77dc166
commit 80188ae6e6
1 changed files with 32 additions and 7 deletions

View File

@ -208,22 +208,47 @@ namespace YooAsset
// Check error
if (CacheBundle == null)
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Failed to load assetBundle : {MainBundleInfo.Bundle.BundleName}";
YooLogger.Error(LastError);
// 注意当缓存文件的校验等级为Low的时候并不能保证缓存文件的完整性。
// 在AssetBundle文件加载失败的情况下我们需要重新验证文件的完整性
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
{
var result = MainBundleInfo.VerifySelf();
if (result != EVerifyResult.Succeed)
if (result == EVerifyResult.Succeed)
{
YooLogger.Error($"Found possibly corrupt file ! {MainBundleInfo.Bundle.CacheGUID} Verify result : {result}");
// 说明:在安卓移动平台,华为和三星真机上有极小概率加载资源包失败。
// 大多数情况在首次安装下载资源到沙盒内,游戏过程中切换到后台再回到游戏内有很大概率触发!
byte[] fileData = FileUtility.ReadAllBytes(FileLoadPath);
if (fileData != null && fileData.Length > 0)
CacheBundle = AssetBundle.LoadFromMemory(fileData);
if (CacheBundle == null)
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Failed to load assetBundle from memory : {MainBundleInfo.Bundle.BundleName}";
YooLogger.Error(LastError);
}
else
{
_steps = ESteps.Done;
Status = EStatus.Succeed;
}
}
else
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Found possibly corrupt file ! {MainBundleInfo.Bundle.CacheGUID} Verify result : {result}";
YooLogger.Error(LastError);
MainBundleInfo.CacheDiscard();
}
}
else
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Failed to load assetBundle : {MainBundleInfo.Bundle.BundleName}";
YooLogger.Error(LastError);
}
}
else
{