diff --git a/Explorer/Assets/DCL/AvatarRendering/Thumbnails/Systems/ResolveAvatarAttachmentThumbnailSystem.cs b/Explorer/Assets/DCL/AvatarRendering/Thumbnails/Systems/ResolveAvatarAttachmentThumbnailSystem.cs index c6271ab45b..5ddc9e4376 100644 --- a/Explorer/Assets/DCL/AvatarRendering/Thumbnails/Systems/ResolveAvatarAttachmentThumbnailSystem.cs +++ b/Explorer/Assets/DCL/AvatarRendering/Thumbnails/Systems/ResolveAvatarAttachmentThumbnailSystem.cs @@ -32,7 +32,11 @@ protected override void Update(float t) private void CompleteWearableABThumbnailDownload(Entity entity, ref IAvatarAttachment wearable, ref AssetBundlePromise promise) { if (promise.TryForgetWithEntityIfCancelled(entity, World!)) + { + wearable.ThumbnailAssetResult = null; return; + } + if (promise.TryConsume(World, out var result)) { @@ -45,12 +49,14 @@ private void CompleteWearableABThumbnailDownload(Entity entity, ref IAvatarAttac private void CompleteWearableThumbnailDownload(Entity entity, ref IAvatarAttachment wearable, ref Promise promise) { if (promise.TryForgetWithEntityIfCancelled(entity, World!)) + { + wearable.ThumbnailAssetResult = null; return; + } if (promise.TryConsume(World, out StreamableLoadingResult result)) { wearable.ThumbnailAssetResult = result.ToFullRectSpriteData(LoadThumbnailsUtils.DEFAULT_THUMBNAIL); - World.Destroy(entity); } } diff --git a/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs b/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs index 4dae2360a1..ccfb45c6f5 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs @@ -27,7 +27,6 @@ public class ECSPortableExperiencesController : IPortableExperiencesController private readonly IScenesCache scenesCache; private readonly World globalWorld; private readonly List spawnResponsesList = new (); - private readonly ServerAbout serverAbout = new (); private readonly FeatureFlagsCache featureFlagsCache; public Dictionary PortableExperienceEntities { get; } = new (); @@ -61,17 +60,20 @@ public ECSPortableExperiencesController( } } + if (PortableExperienceEntities.ContainsKey(ens)) throw new Exception($"ENS {ens} is already loaded"); + string worldUrl = string.Empty; if (ens.IsValid) { worldUrl = ens.ConvertEnsToWorldUrl(); } - if (!worldUrl.IsValidUrl()) throw new ArgumentException("Invalid Spawn params. Provide a valid ENS name"); + if (!worldUrl.IsValidUrl()) throw new ArgumentException($"Invalid Spawn params. Provide a valid ENS name {ens}"); var portableExperiencePath = URLDomain.FromString(worldUrl); URLAddress url = portableExperiencePath.Append(new URLPath("/about")); GenericDownloadHandlerUtils.Adapter genericGetRequest = webRequestController.GetAsync(new CommonArguments(url), ct, ReportCategory.REALM); + ServerAbout serverAbout = new ServerAbout(); ServerAbout result = await genericGetRequest.OverwriteFromJsonAsync(serverAbout, WRJsonParser.Unity); if (result.configurations.scenesUrn.Count == 0) @@ -90,9 +92,11 @@ public ECSPortableExperiencesController( portableExperiencePath.Value ); + ISceneFacade parentScene = scenesCache.Scenes.FirstOrDefault(s => s.SceneStateProvider.IsCurrent); string parentSceneName = parentScene != null ? parentScene.Info.Name : "main"; Entity portableExperienceEntity = globalWorld.Create(new PortableExperienceRealmComponent(realmData, parentSceneName, isGlobalPortableExperience), new PortableExperienceComponent(ens)); + PortableExperienceEntities.Add(ens, portableExperienceEntity); return new IPortableExperiencesController.SpawnResponse