Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
feat: logs to understand login
Browse files Browse the repository at this point in the history
  • Loading branch information
eordano committed Jan 25, 2023
1 parent c973e59 commit ef13b8b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/entryPoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 })
Expand All @@ -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.
{
Expand All @@ -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
Expand Down Expand Up @@ -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')

Expand All @@ -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
}

Expand Down
20 changes: 20 additions & 0 deletions packages/shared/session/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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))

Expand All @@ -122,17 +136,21 @@ 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,
identity.address,
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
Expand All @@ -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) {
Expand Down

0 comments on commit ef13b8b

Please sign in to comment.