Skip to content

Commit bc80fc8

Browse files
fix(core): add status checks after synchronous asset loading
Validate handle.Status before accessing asset objects to prevent null reference exceptions when sync loads fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net>
1 parent abfbba7 commit bc80fc8

File tree

1 file changed

+14
-0
lines changed
  • UnityProject/Packages/com.jasonxudeveloper.jengine.core/Runtime

1 file changed

+14
-0
lines changed

UnityProject/Packages/com.jasonxudeveloper.jengine.core/Runtime/Bootstrap.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ private async UniTask SetUpDynamicSecret()
155155
private void LoadMetadataForAOTAssemblies()
156156
{
157157
var aotListHandle = YooAssets.LoadAssetSync<TextAsset>(aotDllListFilePath);
158+
if (aotListHandle.Status != EOperationStatus.Succeed)
159+
{
160+
Debug.LogError($"Failed to load AOT DLL list: {aotListHandle.LastError}");
161+
aotListHandle.Release();
162+
return;
163+
}
164+
158165
TextAsset aotDataAsset = aotListHandle.GetAssetObject<TextAsset>();
159166
var aotDllList = NinoDeserializer.Deserialize<List<string>>(aotDataAsset.bytes);
160167
aotListHandle.Release();
@@ -168,6 +175,13 @@ private void LoadMetadataForAOTAssemblies()
168175
}
169176

170177
var handle = YooAssets.LoadAssetSync<TextAsset>(aotDllName);
178+
if (handle.Status != EOperationStatus.Succeed)
179+
{
180+
Debug.LogError($"Failed to load AOT DLL {aotDllName}: {handle.LastError}");
181+
handle.Release();
182+
continue;
183+
}
184+
171185
byte[] dllBytes = handle.GetAssetObject<TextAsset>().bytes;
172186
var err = RuntimeApi.LoadMetadataForAOTAssembly(dllBytes, HomologousImageMode.SuperSet);
173187
Debug.Log($"LoadMetadataForAOTAssembly:{aotDllName}. ret:{err}");

0 commit comments

Comments
 (0)