Skip to content

Commit cc56e4d

Browse files
fix: null-safe budget release in LoadAssetBundleSystem
The pooled StreamableLoadingState can be recycled (budget disposed and nulled via the pool actionOnRelease) if the promise is forgotten or cancelled while the detached flow is mid-await. Releasing the budget with !. would NRE in that window, so guard with ?. to match how the budget is treated everywhere else in the flow.
1 parent bcb6b1b commit cc56e4d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Explorer/Assets/DCL/Infrastructure/ECS/Unity/StreamableLoading/AssetBundles/LoadAssetBundleSystem.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ protected override async UniTask<StreamableLoadingResult<AssetBundleData>> FlowI
9696
}
9797

9898
// Release budget now to not hold it until dependencies are resolved to prevent a deadlock
99-
state.AcquiredBudget!.Release();
99+
// Null-safe: the pooled state can be recycled (budget disposed and nulled) if the promise is
100+
// forgotten/cancelled while this detached flow is mid-await
101+
state.AcquiredBudget?.Release();
100102

101103
// if GetContent prints an error, null will be thrown
102104
if (assetBundle == null)

0 commit comments

Comments
 (0)