diff --git a/Explorer/Assets/DCL/PluginSystem/World/AudioAnalysisPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/AudioAnalysisPlugin.cs index c9ec53a2378..49a9fcb5bc0 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/AudioAnalysisPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/AudioAnalysisPlugin.cs @@ -41,9 +41,7 @@ public void Dispose() { } - public async UniTask InitializeAsync(CancellationToken ct) - { - } + public UniTask InitializeAsync(CancellationToken ct) => UniTask.CompletedTask; } } diff --git a/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs index c322a67263e..7bc6a4f0ccb 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs @@ -80,11 +80,12 @@ public async UniTask InitializeAsync(LightSourcePluginSettings settings, Cancell await CreateLightSourcePoolAsync(lightSourcePrefab, ct); } - private async UniTask CreateLightSourcePoolAsync(Light lightSourcePrefab, CancellationToken ct) + private UniTask CreateLightSourcePoolAsync(Light lightSourcePrefab, CancellationToken ct) { lightPoolRegistry = poolsRegistry.AddGameObjectPool(() => Object.Instantiate(lightSourcePrefab, Vector3.zero, quaternion.identity), onRelease: OnPoolRelease, onGet: OnPoolGet); cacheCleaner.Register(lightPoolRegistry); + return UniTask.CompletedTask; } private void OnPoolRelease(Light light) diff --git a/Explorer/Assets/DCL/SDKComponents/AudioAnalysis/AudioAnalysisSystem.cs b/Explorer/Assets/DCL/SDKComponents/AudioAnalysis/AudioAnalysisSystem.cs index 5a345f7a0d2..42c4e6f78b3 100644 --- a/Explorer/Assets/DCL/SDKComponents/AudioAnalysis/AudioAnalysisSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/AudioAnalysis/AudioAnalysisSystem.cs @@ -88,6 +88,10 @@ ref PBAudioAnalysis sdkComponent { PBAudioAnalysisMode.ModeRaw => AnalysisResultMode.Raw, PBAudioAnalysisMode.ModeLogarithmic => AnalysisResultMode.Logarithmic, + + // proto3 open enum: scene wire data can carry any out-of-range value; fall back + // to the default mode instead of throwing every frame. + _ => AnalysisResultMode.Raw, }; float amplitudeGain = sdkComponent.HasAmplitudeGain ? sdkComponent.AmplitudeGain : DEFAULT_AMPLITUDE_GAIN; float bandsGain = sdkComponent.HasBandsGain ? sdkComponent.BandsGain : DEFAULT_BANDS_GAIN; diff --git a/Explorer/Assets/DCL/SDKComponents/MediaStream/AnyTexture.cs b/Explorer/Assets/DCL/SDKComponents/MediaStream/AnyTexture.cs index 49cf8cd86de..70e48b92e0b 100644 --- a/Explorer/Assets/DCL/SDKComponents/MediaStream/AnyTexture.cs +++ b/Explorer/Assets/DCL/SDKComponents/MediaStream/AnyTexture.cs @@ -1,5 +1,6 @@ using REnum; using UnityEngine; +using UnityEngine.Experimental.Rendering; using Utility; namespace ECS.StreamableLoading.Textures @@ -12,7 +13,23 @@ namespace ECS.StreamableLoading.Textures [REnumField(typeof(Texture2D))] public partial struct AnyTexture { - public long ByteSize => Match(static _ => 0L, tex2d => tex2d.GetRawTextureData().Length); + public long ByteSize => Match(static _ => 0L, static tex2d => EstimateTextureByteSize(tex2d)); + + private static long EstimateTextureByteSize(Texture2D tex2d) + { + // Destroyed textures (Unity fake-null) account as zero instead of throwing. + if (tex2d == null) return 0L; + if (tex2d.isReadable) return tex2d.GetRawTextureData().Length; + + // Non-readable textures have no CPU copy to measure (GetRawTextureData throws); + // estimate the GPU footprint across the full mip chain instead. + var size = (long)GraphicsFormatUtility.ComputeMipmapSize(tex2d.width, tex2d.height, tex2d.graphicsFormat); + + for (var mip = 1; mip < tex2d.mipmapCount; mip++) + size += (long)GraphicsFormatUtility.ComputeMipmapSize(Mathf.Max(1, tex2d.width >> mip), Mathf.Max(1, tex2d.height >> mip), tex2d.graphicsFormat); + + return size; + } public Texture Texture => Match(static video => video.Texture, static tex2d => tex2d);