@@ -273,14 +273,20 @@ public async Task LoadBankAsync(WwiseAddressableSoundBank bank, AssetReferenceWw
273273 {
274274 var asyncHandle = bankData . LoadAssetAsync < WwiseSoundBankAsset > ( ) ;
275275 WwiseSoundBankAsset soundBankAsset ;
276- if ( loadAsync )
276+ #if UNITY_WEBGL && ! UNITY_EDITOR
277+ // On WebGL, we MUST load asynchronously in order to yield back to the browser.
278+ // Failing to do so will result in the thread blocking forever and the asset will never be loaded.
279+ soundBankAsset = await asyncHandle . Task ;
280+ #else
281+ if ( loadAsync )
277282 {
278283 soundBankAsset = await asyncHandle . Task ;
279284 }
280285 else
281286 {
282287 soundBankAsset = asyncHandle . WaitForCompletion ( ) ;
283288 }
289+ #endif
284290 //AsyncHandle gets corrupted in Unity 2021 but properly returns the loaded Asset as expected
285291#if UNITY_2021_1_OR_NEWER
286292 if ( soundBankAsset )
@@ -338,8 +344,13 @@ public async Task LoadBankAsync(WwiseAddressableSoundBank bank, AssetReferenceWw
338344 {
339345 AkAssetUtilities . UpdateWwiseFileIfNecessary ( WriteableMediaDirectory , streamingMedia ) ;
340346 } , Addressables . MergeMode . Union , false ) ;
341-
347+ #if UNITY_WEBGL && ! UNITY_EDITOR
348+ // On WebGL, we MUST load asynchronously in order to yield back to the browser.
349+ // Failing to do so will result in the thread blocking forever and the asset will never be loaded.
350+ await streamingAssetAsyncHandle . Task ;
351+ #else
342352 streamingAssetAsyncHandle . WaitForCompletion ( ) ;
353+ #endif
343354
344355 Addressables . Release ( streamingAssetAsyncHandle ) ;
345356 }
0 commit comments