Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/AvatarWithIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function AvatarWithIndicator({source, accountID, tooltipText = '', fallbackIcon,
<Tooltip text={tooltipText}>
<View style={[styles.sidebarAvatar]}>
{isLoading ? (
<AvatarSkeleton />
<AvatarSkeleton reasonAttributes={{context: 'AvatarWithIndicator', isLoading}} />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Memoize skeleton reasonAttributes objects

Passing an inline reasonAttributes object here causes a new reference on every render, and useSkeletonSpan reacts to that by calling span.setAttributes and span.addEvent on every rerender (src/libs/telemetry/useSkeletonSpan.ts:56-65), even when the values did not change. While the avatar is loading, normal rerenders (theme/Onyx/layout updates) can therefore generate noisy telemetry and extra span work that obscures true infinite-loading signals; the same pattern is also introduced in ProfilePage and should be memoized/hoisted there as well.

Useful? React with 👍 / 👎.

) : (
<>
<Avatar
Expand Down
10 changes: 9 additions & 1 deletion src/pages/settings/Profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,15 @@ function ProfilePage() {
>
<View style={[styles.pt3, styles.pb6, styles.alignSelfStart, styles.w100]}>
{isEmptyObject(currentUserPersonalDetails) || accountID === -1 || !avatarURL ? (
<AvatarSkeleton size={CONST.AVATAR_SIZE.X_LARGE} />
<AvatarSkeleton
size={CONST.AVATAR_SIZE.X_LARGE}
reasonAttributes={{
context: 'ProfilePage',
isPersonalDetailsEmpty: isEmptyObject(currentUserPersonalDetails),
isAccountIDInvalid: accountID === -1,
hasNoAvatarURL: !avatarURL,
}}
/>
) : (
<MenuItemGroup shouldUseSingleExecution={false}>
<AvatarButtonWithIcon
Expand Down
Loading