diff --git a/packages/entryPoints/index.ts b/packages/entryPoints/index.ts index 223d7b6f0..1656de163 100644 --- a/packages/entryPoints/index.ts +++ b/packages/entryPoints/index.ts @@ -181,12 +181,24 @@ globalThis.DecentralandKernel = { } async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) { + function now() { + return new Date().getTime() + } + let lastTime = now() + function mark(a: any) { + const thisTime = now() + logger.info(`${new Date().toISOString()} (+${thisTime - lastTime}): mark ${a}`) + lastTime = now() + } + mark(`starting load website systems`) const i = (await ensureUnityInterface()).unityInterface + mark(`unity ensured`) // NOTE(Brian): Scene download manager uses meta config to determine which empty parcels we want // so ensuring meta configuration is initialized in this stage is a must // NOTE(Pablo): We also need meta configuration to know if we need to enable voice chat await ensureMetaConfigurationInitialized() + mark(`meta ensured`) //Note: This should be sent to unity before any other feature because some features may need a system init from FeatureFlag // For example disable AssetBundles needs a system from FeatureFlag @@ -196,13 +208,16 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) { const worldConfig: WorldConfig | undefined = getWorldConfig(store.getState()) const renderProfile = worldConfig ? worldConfig.renderProfile ?? RenderProfile.DEFAULT : RenderProfile.DEFAULT i.SetRenderProfile(renderProfile) + mark(`profile set and ensured`) // killswitch, disable asset bundles if (!getFeatureFlagEnabled(store.getState(), 'asset_bundles')) { i.SetDisableAssetBundles() } + mark(`starting huds...`) i.ConfigureHUDElement(HUDElementID.MINIMAP, { active: true, visible: true }) + mark(`after minimap hud`) i.ConfigureHUDElement(HUDElementID.NOTIFICATION, { active: true, visible: true }) i.ConfigureHUDElement(HUDElementID.AVATAR_EDITOR, { active: true, visible: OPEN_AVATAR_EDITOR }) i.ConfigureHUDElement(HUDElementID.SIGNUP, { active: true, visible: false }) @@ -220,6 +235,7 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) { i.ConfigureHUDElement(HUDElementID.QUESTS_PANEL, { active: questEnabled, visible: false }) i.ConfigureHUDElement(HUDElementID.QUESTS_TRACKER, { active: questEnabled, visible: true }) i.ConfigureHUDElement(HUDElementID.PROFILE_HUD, { active: true, visible: true }) + mark(`after all the other huds`) // The elements below, require the taskbar to be active before being activated. { @@ -232,19 +248,27 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) { i.ConfigureHUDElement(HUDElementID.CONTROLS_HUD, { active: true, visible: false }) i.ConfigureHUDElement(HUDElementID.HELP_AND_SUPPORT_HUD, { active: true, visible: false }) } + mark(`after taskbar huds`) const configForRenderer = kernelConfigForRenderer() configForRenderer.comms.voiceChatEnabled = true + mark(`before set config`) + i.SetKernelConfiguration(configForRenderer) i.ConfigureHUDElement(HUDElementID.USERS_AROUND_LIST_HUD, { active: true, visible: false }) i.ConfigureHUDElement(HUDElementID.GRAPHIC_CARD_WARNING, { active: true, visible: true }) + mark(`after set config`) + await onLoginCompleted() + mark(`after login completed`) const identity = getCurrentIdentity(store.getState())! const profile = getCurrentUserProfile(store.getState())! + mark(`after currentProfile sent`) + if (!profile) { BringDownClientAndReportFatalError(new Error('Profile missing during unity initialization'), 'kernel#init') return @@ -282,6 +306,8 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) { } } + mark(`after tutorial sent`) + const isGuest = !identity.hasConnectedWeb3 const friendsActivated = !isGuest && !getFeatureFlagEnabled(store.getState(), 'matrix_disabled') @@ -304,9 +330,11 @@ async function loadWebsiteSystems(options: KernelOptions['kernelOptions']) { i.SetDisableAssetBundles() await startPreview(i) } + mark(`asking for realm initialized...`) await realmInitialized() + mark(`realm initialized!`) return true } diff --git a/packages/shared/session/sagas.ts b/packages/shared/session/sagas.ts index b52978514..c287c95ae 100644 --- a/packages/shared/session/sagas.ts +++ b/packages/shared/session/sagas.ts @@ -92,16 +92,28 @@ function* initSession() { } function* authenticate(action: AuthenticateAction) { + function now() { + return new Date().getTime() + } + let lastTime = now() + function mark(a: any) { + const thisTime = now() + logger.info(`${new Date().toISOString()} (+${thisTime - lastTime}): mark ${a}`) + lastTime = now() + } + mark(`starting auth`) const { isGuest, provider } = action.payload // setup provider requestManager.setProvider(provider) yield put(changeLoginState(LoginState.SIGNATURE_PENDING)) + mark(`pending sig`) let identity: ExplorerIdentity try { identity = yield authorize(requestManager) + mark(`got auth`) } catch (e: any) { if (('' + (e.message || e.toString())).includes('User denied message signature')) { yield put(signUpCancel()) @@ -111,9 +123,11 @@ function* authenticate(action: AuthenticateAction) { } } + mark(`do I have renderer?`) yield put(changeLoginState(LoginState.WAITING_RENDERER)) yield call(waitForRendererInstance) + mark(`I do, and renderer is init`) yield put(changeLoginState(LoginState.WAITING_PROFILE)) @@ -122,10 +136,13 @@ function* authenticate(action: AuthenticateAction) { yield put(selectNetwork(net)) registerProviderNetChanges() + mark(`let's auth`) // 1. authenticate our user yield put(userAuthentified(identity, net, isGuest)) + mark(`let's wait for comms auth`) // 2. wait for comms to connect, it only requires the Identity authentication yield call(waitForRoomConnection) + mark(`I have room`) // 3. then ask for our profile const avatar: Avatar = yield call( ProfileAsPromise, @@ -133,6 +150,7 @@ function* authenticate(action: AuthenticateAction) { 0, isGuest ? ProfileType.LOCAL : ProfileType.DEPLOYED ) + mark(`I have avatar`) // 4. continue with signin/signup (only not in preview) const isSignUp = avatar.version <= 0 && !PREVIEW @@ -142,7 +160,9 @@ function* authenticate(action: AuthenticateAction) { } // 5. finish sign in + mark(`but do I have meta?`) yield call(ensureMetaConfigurationInitialized) + mark(`yes I do -- Login state completed`) yield put(changeLoginState(LoginState.COMPLETED)) if (!isGuest) {