Skip to content

Commit af1168f

Browse files
fix(core): use synchronous asset loading for AOT metadata (#630)
LoadMetadataForAOTAssemblies used LoadAssetAsync + await per file, causing N+ frames of unnecessary delay during initialization. Since this runs before gameplay, synchronous loading is safe and eliminates the frame-per-file overhead. Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3846147 commit af1168f

File tree

1 file changed

+18
-6
lines changed
  • UnityProject/Packages/com.jasonxudeveloper.jengine.core/Runtime

1 file changed

+18
-6
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,16 @@ private async UniTask SetUpDynamicSecret()
152152
Debug.Log("SetUpDynamicSecret end");
153153
}
154154

155-
private async UniTask LoadMetadataForAOTAssemblies()
155+
private void LoadMetadataForAOTAssemblies()
156156
{
157-
var aotListHandle = YooAssets.LoadAssetAsync<TextAsset>(aotDllListFilePath);
158-
await aotListHandle.Task;
157+
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+
159165
TextAsset aotDataAsset = aotListHandle.GetAssetObject<TextAsset>();
160166
var aotDllList = NinoDeserializer.Deserialize<List<string>>(aotDataAsset.bytes);
161167
aotListHandle.Release();
@@ -168,8 +174,14 @@ private async UniTask LoadMetadataForAOTAssemblies()
168174
continue;
169175
}
170176

171-
var handle = YooAssets.LoadAssetAsync<TextAsset>(aotDllName);
172-
await handle.Task;
177+
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+
173185
byte[] dllBytes = handle.GetAssetObject<TextAsset>().bytes;
174186
var err = RuntimeApi.LoadMetadataForAOTAssembly(dllBytes, HomologousImageMode.SuperSet);
175187
Debug.Log($"LoadMetadataForAOTAssembly:{aotDllName}. ret:{err}");
@@ -293,7 +305,7 @@ await Prompt.ShowDialogAsync(t.dialogTitleNotice,
293305

294306
// First supplement metadata
295307
updateStatusText.text = text.loadingCode;
296-
await LoadMetadataForAOTAssemblies();
308+
LoadMetadataForAOTAssemblies();
297309
// Set dynamic key
298310
updateStatusText.text = text.decryptingResources;
299311
await SetUpDynamicSecret();

0 commit comments

Comments
 (0)