From ad579eb5106c6a903a3edb2f56fd65247618082e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Thu, 19 Dec 2024 17:17:13 -0300 Subject: [PATCH] fix: logout flow (#3018) * Logout flow * Be in Mordor while scene loads * Clear chat history and mordor position encapsulation * UNload PX, remove unnecessary RestartRealmOperation, start gathering logout operations * Deleted RestartRealmStartupOperation * Rollback on condition of `SceneRoomMetaDataSource` * Fixed issue with PXs entities being removed when changing realm * Fixed issue with PX scene entity not being properly removed after killing a PX * Fix async method * Unified mordor constants and moved the file to a better location --------- Co-authored-by: Fran Colarich <56565104+fcolarich@users.noreply.github.com> --- .../Systems/TeleportCharacterSystem.cs | 4 + .../PluginSystem/World/TransformsPlugin.cs | 2 +- .../Systems/AvatarAttachHandlerSystem.cs | 9 +- .../ConnectionStatusPanelController.cs | 1 - .../DCL/UI/SystemMenu/SystemMenuController.cs | 5 - .../DCL.UserInAppInitializationFlow.asmdef | 3 +- .../RealUserInAppInitializationFlow.cs | 119 ++++++++++-------- .../RestartRealmStartupOperation.cs | 43 ------- .../UserInAppInitializationFlowParameters.cs | 3 - .../Assets/DCL/Utilities/MordorConstants.cs | 8 ++ .../MordorConstants.cs.meta} | 2 +- .../SceneLifeCycle/Realm/IRealmNavigator.cs | 2 + .../Systems/UnloadSceneSystem.cs | 2 +- .../Scripts/Global/Dynamic/Bootstraper.cs | 1 - .../Global/Dynamic/DynamicWorldContainer.cs | 6 +- .../MainScreenFallbackRealmNavigator.cs | 6 +- .../ECSPortableExperiencesController.cs | 6 + .../IPortableExperiencesController.cs | 2 + .../Scripts/Global/Dynamic/RealmController.cs | 2 +- .../Scripts/Global/Dynamic/RealmNavigator.cs | 6 + 20 files changed, 113 insertions(+), 119 deletions(-) delete mode 100644 Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs create mode 100644 Explorer/Assets/DCL/Utilities/MordorConstants.cs rename Explorer/Assets/DCL/{UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs.meta => Utilities/MordorConstants.cs.meta} (83%) diff --git a/Explorer/Assets/DCL/Character/CharacterMotion/Systems/TeleportCharacterSystem.cs b/Explorer/Assets/DCL/Character/CharacterMotion/Systems/TeleportCharacterSystem.cs index 5d70b4df2f..9803fcc63b 100644 --- a/Explorer/Assets/DCL/Character/CharacterMotion/Systems/TeleportCharacterSystem.cs +++ b/Explorer/Assets/DCL/Character/CharacterMotion/Systems/TeleportCharacterSystem.cs @@ -51,6 +51,10 @@ private void TeleportPlayer(Entity entity, CharacterController controller, ref C switch (status.TaskStatus) { + case UniTaskStatus.Pending: + // Teleport the character to a far away place while the teleport is executed + controller.transform.position = MordorConstants.PLAYER_MORDOR_POSITION; + return; case UniTaskStatus.Succeeded: ResolveAsSuccess(entity, in teleportIntent, controller, ref platformComponent); return; diff --git a/Explorer/Assets/DCL/PluginSystem/World/TransformsPlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/TransformsPlugin.cs index c3979ecfcc..d9ae320412 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/TransformsPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/World/TransformsPlugin.cs @@ -61,7 +61,7 @@ private void CreateReservedTransforms(ArchSystemsWorldBuilder b { //The scene container, which is only modified by the client, starts in a position that cannot be seen by the player. Once it finished loading //in GatherGLTFAssetSystem.cs, it will be moved to the correct position. - var sceneRootContainerTransform = GetNewTransform(position: new Vector3(0, -10000, 0)); + var sceneRootContainerTransform = GetNewTransform(position: MordorConstants.SCENE_MORDOR_POSITION); sceneRootContainerTransform.name = $"{sharedDependencies.SceneData.SceneShortInfo.BaseParcel}_{sharedDependencies.SceneData.SceneShortInfo.Name}_Container"; builder.World.Add(persistentEntities.SceneContainer, new TransformComponent(sceneRootContainerTransform)); diff --git a/Explorer/Assets/DCL/SDKComponents/AvatarAttach/Systems/AvatarAttachHandlerSystem.cs b/Explorer/Assets/DCL/SDKComponents/AvatarAttach/Systems/AvatarAttachHandlerSystem.cs index 9f55d7d360..272871e4f6 100644 --- a/Explorer/Assets/DCL/SDKComponents/AvatarAttach/Systems/AvatarAttachHandlerSystem.cs +++ b/Explorer/Assets/DCL/SDKComponents/AvatarAttach/Systems/AvatarAttachHandlerSystem.cs @@ -12,8 +12,6 @@ using ECS.LifeCycle.Components; using ECS.Unity.Transforms.Components; using SceneRunner.Scene; -using System; -using UnityEngine; namespace DCL.SDKComponents.AvatarAttach.Systems { @@ -21,11 +19,6 @@ namespace DCL.SDKComponents.AvatarAttach.Systems [LogCategory(ReportCategory.AVATAR_ATTACH)] public partial class AvatarAttachHandlerSystem : BaseUnityLoopSystem, IFinalizeWorldSystem { - /// - /// Integrated from the previous implementation - /// - private static readonly Vector3 MORDOR = Vector3.one * 8000; - private static readonly QueryDescription ENTITY_DESTRUCTION_QUERY = new QueryDescription().WithAll(); private static readonly QueryDescription COMPONENT_REMOVAL_QUERY = new QueryDescription().WithAll().WithNone(); private readonly ObjectProxy mainPlayerAvatarBaseProxy; @@ -54,7 +47,7 @@ protected override void Update(float t) private void HideDetached(ref TransformComponent transformComponent) { if (!sceneStateProvider.IsCurrent) return; - transformComponent.Apply(MORDOR); + transformComponent.Apply(MordorConstants.AVATAR_ATTACH_MORDOR_POSITION); } [Query] diff --git a/Explorer/Assets/DCL/UI/ConnectionStatusPanel/ConnectionStatusPanelController.cs b/Explorer/Assets/DCL/UI/ConnectionStatusPanel/ConnectionStatusPanelController.cs index 44d49dffef..4face4bb05 100644 --- a/Explorer/Assets/DCL/UI/ConnectionStatusPanel/ConnectionStatusPanelController.cs +++ b/Explorer/Assets/DCL/UI/ConnectionStatusPanel/ConnectionStatusPanelController.cs @@ -124,7 +124,6 @@ await userInAppInitializationFlow.ExecuteAsync( new UserInAppInitializationFlowParameters( showAuthentication: true, showLoading: true, - reloadRealm: true, loadSource: IUserInAppInitializationFlow.LoadSource.Recover, world: world, playerEntity: playerEntity diff --git a/Explorer/Assets/DCL/UI/SystemMenu/SystemMenuController.cs b/Explorer/Assets/DCL/UI/SystemMenu/SystemMenuController.cs index 106408ff91..99b0b6bc22 100644 --- a/Explorer/Assets/DCL/UI/SystemMenu/SystemMenuController.cs +++ b/Explorer/Assets/DCL/UI/SystemMenu/SystemMenuController.cs @@ -122,14 +122,9 @@ async UniTaskVoid LogoutAsync(CancellationToken ct) profileCache.Remove(address); await userInAppInitializationFlow.ExecuteAsync( - - // We have to reload the realm so the scenes are recreated when coming back to the world - // The realm fetches the scene entity definitions again and creates the components in ecs - // so the SceneFacade can be later attached into the entity new UserInAppInitializationFlowParameters( showAuthentication: true, showLoading: true, - reloadRealm: true, loadSource: IUserInAppInitializationFlow.LoadSource.Logout, world: world, playerEntity: playerEntity diff --git a/Explorer/Assets/DCL/UserInAppInitializationFlow/DCL.UserInAppInitializationFlow.asmdef b/Explorer/Assets/DCL/UserInAppInitializationFlow/DCL.UserInAppInitializationFlow.asmdef index 31ca067ae1..7f650c2722 100644 --- a/Explorer/Assets/DCL/UserInAppInitializationFlow/DCL.UserInAppInitializationFlow.asmdef +++ b/Explorer/Assets/DCL/UserInAppInitializationFlow/DCL.UserInAppInitializationFlow.asmdef @@ -37,7 +37,8 @@ "GUID:a285ec5e26824438b1b2ab8f22969298", "GUID:e169fa6683c924c7e99a85981a91d953", "GUID:e25ef972de004615a22937e739de2def", - "GUID:d28a7e4beeca475418c15757abf1b6f1" + "GUID:d28a7e4beeca475418c15757abf1b6f1", + "GUID:766b242fb43af451aaa331f39872177d" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/UserInAppInitializationFlow/RealUserInAppInitializationFlow.cs b/Explorer/Assets/DCL/UserInAppInitializationFlow/RealUserInAppInitializationFlow.cs index ee48cda680..549d91d7e6 100644 --- a/Explorer/Assets/DCL/UserInAppInitializationFlow/RealUserInAppInitializationFlow.cs +++ b/Explorer/Assets/DCL/UserInAppInitializationFlow/RealUserInAppInitializationFlow.cs @@ -1,10 +1,12 @@ -using CommunicationData.URLHelpers; using System; using System.Threading; +using System.Threading.Tasks; +using CommunicationData.URLHelpers; using Cysharp.Threading.Tasks; using DCL.Audio; using DCL.AuthenticationScreenFlow; using DCL.AvatarRendering.AvatarShape.UnityInterface; +using DCL.Chat.History; using DCL.Diagnostics; using DCL.FeatureFlags; using DCL.Multiplayer.Connections.DecentralandUrls; @@ -33,16 +35,20 @@ public class RealUserInAppInitializationFlow : IUserInAppInitializationFlow private static readonly ILoadingScreen.EmptyLoadingScreen EMPTY_LOADING_SCREEN = new (); private readonly ILoadingStatus loadingStatus; - private readonly IDecentralandUrlsSource decentralandUrlsSource; private readonly IMVCManager mvcManager; private readonly AudioClipConfig backgroundMusic; private readonly IRealmNavigator realmNavigator; private readonly ILoadingScreen loadingScreen; - private readonly IRoomHub roomHub; private readonly LoadPlayerAvatarStartupOperation loadPlayerAvatarStartupOperation; private readonly CheckOnboardingStartupOperation checkOnboardingStartupOperation; - private readonly RestartRealmStartupOperation restartRealmStartupOperation; private readonly IStartupOperation startupOperation; + private readonly IStartupOperation reloginOperation; + private readonly IDecentralandUrlsSource decentralandUrlsSource; + private readonly IChatHistory chatHistory; + + private readonly IRealmController realmController; + private readonly IRoomHub roomHub; + private readonly IPortableExperiencesController portableExperiencesController; public RealUserInAppInitializationFlow( ILoadingStatus loadingStatus, @@ -67,7 +73,7 @@ public RealUserInAppInitializationFlow( IRoomHub roomHub, IAnalyticsController analyticsController, DiagnosticsContainer diagnosticsContainer, - URLDomain defaultStartingRealm + ChatHistory chatHistory ) { this.loadingStatus = loadingStatus; @@ -76,6 +82,9 @@ URLDomain defaultStartingRealm this.backgroundMusic = backgroundMusic; this.realmNavigator = realmNavigator; this.loadingScreen = loadingScreen; + this.realmController = realmController; + this.portableExperiencesController = portableExperiencesController; + this.chatHistory = chatHistory; this.roomHub = roomHub; var ensureLivekitConnectionStartupOperation = new EnsureLivekitConnectionStartupOperation(loadingStatus, livekitHealthCheck); @@ -85,7 +94,6 @@ URLDomain defaultStartingRealm loadPlayerAvatarStartupOperation = new LoadPlayerAvatarStartupOperation(loadingStatus, selfProfile, mainPlayerAvatarBaseProxy); var loadLandscapeStartupOperation = new LoadLandscapeStartupOperation(loadingStatus, landscape); checkOnboardingStartupOperation = new CheckOnboardingStartupOperation(loadingStatus, selfProfile, featureFlagsCache, decentralandUrlsSource, appParameters, realmNavigator); - restartRealmStartupOperation = new RestartRealmStartupOperation(loadingStatus, realmController, defaultStartingRealm); var teleportStartupOperation = new TeleportStartupOperation(loadingStatus, realmNavigator, startParcel); var loadGlobalPxOperation = new LoadGlobalPortableExperiencesStartupOperation(loadingStatus, selfProfile, featureFlagsCache, debugSettings, portableExperiencesController); var sentryDiagnostics = new SentryDiagnosticStartupOperation(realmController, diagnosticsContainer); @@ -99,13 +107,28 @@ URLDomain defaultStartingRealm loadPlayerAvatarStartupOperation, loadLandscapeStartupOperation, checkOnboardingStartupOperation, - restartRealmStartupOperation, teleportStartupOperation, loadGlobalPxOperation, sentryDiagnostics ).WithAnalytics(analyticsController); + + + reloginOperation = new SequentialStartupOperation( + loadingStatus, + ensureLivekitConnectionStartupOperation, + preloadProfileStartupOperation, + switchRealmMiscVisibilityStartupOperation, + loadPlayerAvatarStartupOperation, + loadLandscapeStartupOperation, + checkOnboardingStartupOperation, + teleportStartupOperation, + loadGlobalPxOperation, + sentryDiagnostics).WithAnalytics(analyticsController); + ; + ; } + public async UniTask ExecuteAsync(UserInAppInitializationFlowParameters parameters, CancellationToken ct) { loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.Init); @@ -113,59 +136,49 @@ public async UniTask ExecuteAsync(UserInAppInitializationFlowParameters paramete EnumResult result = parameters.RecoveryError; loadPlayerAvatarStartupOperation.AssignWorld(parameters.World, parameters.PlayerEntity); - restartRealmStartupOperation.EnableReload(parameters.ReloadRealm); using UIAudioEventsBus.PlayAudioScope playAudioScope = UIAudioEventsBus.Instance.NewPlayAudioScope(backgroundMusic); do { - if (parameters.LoadSource is not IUserInAppInitializationFlow.LoadSource.StartUp) - - // Disconnect current livekit connection on logout so the avatar is removed from other peers - await roomHub.StopAsync().Timeout(TimeSpan.FromSeconds(10)); - if (parameters.ShowAuthentication) { loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.AuthenticationScreenShowing); - - await UniTask.WhenAll( - ShowAuthenticationScreenAsync(ct), - ShowErrorPopupIfRequired(result, ct) - ); + if (parameters.LoadSource is IUserInAppInitializationFlow.LoadSource.Logout) + { + await DoLogoutOperationsAsync(); + //Restart the realm and show the authentications screen simultaneously to avoid the "empty space" flicker + //No error should be possible at this point + await UniTask.WhenAll(ShowAuthenticationScreenAsync(ct), + realmController.SetRealmAsync( + URLDomain.FromString(decentralandUrlsSource.Url(DecentralandUrl.Genesis)), ct)); + } + else + { + await UniTask.WhenAll( + ShowAuthenticationScreenAsync(ct), + ShowErrorPopupIfRequired(result, ct) + ); + } } - if (parameters.LoadSource is IUserInAppInitializationFlow.LoadSource.Logout) - { - // If we are coming from a logout, we teleport the user to Genesis Plaza and force realm change to reset the scene properly - var url = URLDomain.FromString(decentralandUrlsSource.Url(DecentralandUrl.Genesis)); - var changeRealmResult = await realmNavigator.TryChangeRealmAsync(url, ct); - - if (changeRealmResult.Success == false) - ReportHub.LogError(ReportCategory.AUTHENTICATION, changeRealmResult.AsResult().ErrorMessage!); - - // Restart livekit connection - await roomHub.StartAsync().Timeout(TimeSpan.FromSeconds(10)); - - result = changeRealmResult.As(ChangeRealmErrors.AsTaskError); + var flowToRun = parameters.LoadSource is IUserInAppInitializationFlow.LoadSource.Logout + ? reloginOperation + : startupOperation; + var loadingResult = await LoadingScreen(parameters.ShowLoading) + .ShowWhileExecuteTaskAsync( + async (parentLoadReport, ct) => + { + var operationResult = await flowToRun.ExecuteAsync(parentLoadReport, ct); + if (operationResult.Success) + parentLoadReport.SetProgress( + loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.Completed)); + return operationResult; + }, + ct + ); - // We need to flag the process as completed, otherwise the multiplayer systems will not run - loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.Completed); - } - else - { - EnumResult loadingResult = await LoadingScreen(parameters.ShowLoading) - .ShowWhileExecuteTaskAsync( - async (parentLoadReport, ct) => - { - var operationResult = await startupOperation.ExecuteAsync(parentLoadReport, ct); - if (operationResult.Success) parentLoadReport.SetProgress(loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.Completed)); - return operationResult; - }, - ct - ); - - result = loadingResult; - } + result = loadingResult; if (result.Success == false) { @@ -179,6 +192,14 @@ await UniTask.WhenAll( loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.Completed); } + private async UniTask DoLogoutOperationsAsync() + { + portableExperiencesController.UnloadAllPortableExperiences(); + realmNavigator.RemoveCameraSamplingData(); + chatHistory.Clear(); + await roomHub.StopAsync().Timeout(TimeSpan.FromSeconds(10)); + } + private async UniTask ShowAuthenticationScreenAsync(CancellationToken ct) { await mvcManager.ShowAsync(AuthenticationScreenController.IssueCommand(), ct); diff --git a/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs b/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs deleted file mode 100644 index 772d497bbb..0000000000 --- a/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs +++ /dev/null @@ -1,43 +0,0 @@ -using CommunicationData.URLHelpers; -using Cysharp.Threading.Tasks; -using DCL.AsyncLoadReporting; -using ECS.SceneLifeCycle.Realm; -using System.Threading; - -namespace DCL.UserInAppInitializationFlow.StartupOperations -{ - public class RestartRealmStartupOperation : StartUpOperationBase - { - private readonly ILoadingStatus loadingStatus; - private readonly IRealmController realmController; - private readonly URLDomain defaultRealm; - private bool reloadRealm; - - public RestartRealmStartupOperation(ILoadingStatus loadingStatus, IRealmController realmController, URLDomain defaultRealm) - { - this.loadingStatus = loadingStatus; - this.realmController = realmController; - this.defaultRealm = defaultRealm; - } - - public void EnableReload(bool enable) - { - reloadRealm = enable; - } - - protected override async UniTask InternalExecuteAsync(AsyncLoadProcessReport report, CancellationToken ct) - { - float finalizationProgress = loadingStatus.SetCurrentStage(LoadingStatus.LoadingStage.RealmRestarting); - - if (reloadRealm) - { - if (realmController.CurrentDomain.HasValue == false) - await realmController.SetRealmAsync(defaultRealm, ct); - else - await realmController.RestartRealmAsync(ct); - } - - report.SetProgress(finalizationProgress); - } - } -} diff --git a/Explorer/Assets/DCL/UserInAppInitializationFlow/UserInAppInitializationFlowParameters.cs b/Explorer/Assets/DCL/UserInAppInitializationFlow/UserInAppInitializationFlowParameters.cs index 52d184734e..73598f612e 100644 --- a/Explorer/Assets/DCL/UserInAppInitializationFlow/UserInAppInitializationFlowParameters.cs +++ b/Explorer/Assets/DCL/UserInAppInitializationFlow/UserInAppInitializationFlowParameters.cs @@ -7,7 +7,6 @@ public readonly struct UserInAppInitializationFlowParameters { public bool ShowAuthentication { get; } public bool ShowLoading { get; } - public bool ReloadRealm { get; } public IUserInAppInitializationFlow.LoadSource LoadSource { get; } public EnumResult RecoveryError { get; } public World World { get; } @@ -16,7 +15,6 @@ public readonly struct UserInAppInitializationFlowParameters public UserInAppInitializationFlowParameters( bool showAuthentication, bool showLoading, - bool reloadRealm, IUserInAppInitializationFlow.LoadSource loadSource, World world, Entity playerEntity, @@ -25,7 +23,6 @@ public UserInAppInitializationFlowParameters( { ShowAuthentication = showAuthentication; ShowLoading = showLoading; - ReloadRealm = reloadRealm; LoadSource = loadSource; World = world; PlayerEntity = playerEntity; diff --git a/Explorer/Assets/DCL/Utilities/MordorConstants.cs b/Explorer/Assets/DCL/Utilities/MordorConstants.cs new file mode 100644 index 0000000000..75242e88c3 --- /dev/null +++ b/Explorer/Assets/DCL/Utilities/MordorConstants.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +public static class MordorConstants +{ + public static readonly Vector3 PLAYER_MORDOR_POSITION = new(15000, 0, 15000); + public static readonly Vector3 SCENE_MORDOR_POSITION = new(0, -10000, 0); + public static readonly Vector3 AVATAR_ATTACH_MORDOR_POSITION = new(8000,0,0); +} diff --git a/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs.meta b/Explorer/Assets/DCL/Utilities/MordorConstants.cs.meta similarity index 83% rename from Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs.meta rename to Explorer/Assets/DCL/Utilities/MordorConstants.cs.meta index 4d744ba09e..4cd6fb278f 100644 --- a/Explorer/Assets/DCL/UserInAppInitializationFlow/StartupOperations/RestartRealmStartupOperation.cs.meta +++ b/Explorer/Assets/DCL/Utilities/MordorConstants.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5da97f7e02354e9283ca78e2b81840de +guid: d6aaaa3e9c49f4b6cbe91de72dbb33e2 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs index 3d177e01eb..8a0583927c 100644 --- a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs +++ b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs @@ -60,5 +60,7 @@ UniTask> TryChangeRealmAsync( UniTask> TeleportToParcelAsync(Vector2Int parcel, CancellationToken ct, bool isLocal); UniTask InitializeTeleportToSpawnPointAsync(AsyncLoadProcessReport teleportLoadReport, CancellationToken ct, Vector2Int parcelToTeleport); + + void RemoveCameraSamplingData(); } } diff --git a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Systems/UnloadSceneSystem.cs b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Systems/UnloadSceneSystem.cs index 17611a1a7a..e3cea1c96b 100644 --- a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Systems/UnloadSceneSystem.cs +++ b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Systems/UnloadSceneSystem.cs @@ -59,7 +59,7 @@ private void UnloadLoadedPortableExperienceScene(in Entity entity, ref SceneDefi { sceneFacade.DisposeAsync().Forget(); scenesCache.RemovePortableExperienceFacade(definitionComponent.IpfsPath.EntityId); - World.Remove(entity); + World.Destroy(entity); } [Query] diff --git a/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs b/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs index f54e440f63..868d9c1ed7 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/Bootstraper.cs @@ -266,7 +266,6 @@ await dynamicWorldContainer.UserInAppInAppInitializationFlow.ExecuteAsync( ( showAuthentication: debugSettings.ShowAuthentication, showLoading: debugSettings.ShowLoading, - reloadRealm: false, IUserInAppInitializationFlow.LoadSource.StartUp, world: globalWorld.EcsWorld, playerEntity: playerEntity diff --git a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs index 33cbd3392d..a7ef9c2f38 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs @@ -391,6 +391,8 @@ IMultiPool MultiPoolFactory() => livekitHealthCheck.WithRetries(); + var chatHistory = new ChatHistory(); + container.UserInAppInAppInitializationFlow = new RealUserInAppInitializationFlow( staticContainer.LoadingStatus, livekitHealthCheck, @@ -414,7 +416,7 @@ IMultiPool MultiPoolFactory() => container.RoomHub, bootstrapContainer.Analytics.EnsureNotNull(), bootstrapContainer.DiagnosticsContainer, - URLDomain.FromString(dynamicWorldParams.DefaultStartingRealm) + chatHistory ); var realmNavigator = new MainScreenFallbackRealmNavigator( @@ -433,8 +435,6 @@ IMultiPool MultiPoolFactory() => container.CharacterDataPropagationUtility = new CharacterDataPropagationUtility(staticContainer.ComponentsContainer.ComponentPoolsRegistry.AddComponentPool()); - var chatHistory = new ChatHistory(); - var currentSceneInfo = new CurrentSceneInfo(); var connectionStatusPanelPlugin = new ConnectionStatusPanelPlugin(container.UserInAppInAppInitializationFlow, container.MvcManager, mainUIView, roomsStatus, currentSceneInfo, container.reloadSceneController, globalWorld, playerEntity, debugBuilder); diff --git a/Explorer/Assets/Scripts/Global/Dynamic/MainScreenFallbackRealmNavigator.cs b/Explorer/Assets/Scripts/Global/Dynamic/MainScreenFallbackRealmNavigator.cs index f8771b0a29..0e76e489c3 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/MainScreenFallbackRealmNavigator.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/MainScreenFallbackRealmNavigator.cs @@ -57,12 +57,16 @@ public async UniTask InitializeTeleportToSpawnPointAsync(AsyncLoadProcessReport } } + public void RemoveCameraSamplingData() + { + origin.RemoveCameraSamplingData(); + } + private void DispatchFallbackToMainScreen(EnumResult recoveryError, CancellationToken ct) { ReportHub.LogError(ReportCategory.DEBUG, "Error during loading. Fallback to main screen"); var parameters = new UserInAppInitializationFlowParameters( - true, true, true, IUserInAppInitializationFlow.LoadSource.Recover, diff --git a/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs b/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs index ccfb45c6f5..0b177e4f91 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/ECSPortableExperiencesController.cs @@ -140,6 +140,12 @@ public bool CanKillPortableExperience(ENS ens) return spawnResponsesList; } + public void UnloadAllPortableExperiences() + { + foreach (var spawnResponse in GetAllPortableExperiences()) + UnloadPortableExperienceByEns(new ENS(spawnResponse.ens)); + } + public IPortableExperiencesController.ExitResponse UnloadPortableExperienceByEns(ENS ens) { if (!ens.IsValid) throw new ArgumentException($"The provided ens {ens.ToString()} is invalid"); diff --git a/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/IPortableExperiencesController.cs b/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/IPortableExperiencesController.cs index 9d6c43b728..5060d0135d 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/IPortableExperiencesController.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/PortableExperiences/IPortableExperiencesController.cs @@ -33,5 +33,7 @@ public struct ExitResponse { public bool status; } + + void UnloadAllPortableExperiences(); } } diff --git a/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs b/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs index bb40c249bb..a78eee2ebe 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs @@ -33,7 +33,7 @@ public class RealmController : IGlobalRealmController // TODO it can be dangerous to clear the realm, instead we may destroy it fully and reconstruct but we will need to // TODO construct player/camera entities again and allocate more memory. Evaluate // Realms + Promises - private static readonly QueryDescription CLEAR_QUERY = new QueryDescription().WithAny(); + private static readonly QueryDescription CLEAR_QUERY = new QueryDescription().WithAny().WithNone(); private readonly List allScenes = new (PoolConstants.SCENES_COUNT); private readonly ServerAbout serverAbout = new (); diff --git a/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs b/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs index 8ea5bf52b5..7287b54cb5 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs @@ -251,6 +251,12 @@ private Func(cameraEntity.Object)) + globalWorld.Remove(cameraEntity.Object); + } + public async UniTask InitializeTeleportToSpawnPointAsync( AsyncLoadProcessReport teleportLoadReport, CancellationToken ct,