Skip to content

Commit

Permalink
Work around a startup stall caused by expo-image on low-end Android (#…
Browse files Browse the repository at this point in the history
…1801)

* Use plain RN image for startup-blocking UI

* Add comments
  • Loading branch information
gaearon authored Nov 3, 2023
1 parent 5e2025e commit 8747c21
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
29 changes: 21 additions & 8 deletions src/view/com/util/UserAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useMemo} from 'react'
import {StyleSheet, View} from 'react-native'
import {Image, StyleSheet, View} from 'react-native'
import Svg, {Circle, Rect, Path} from 'react-native-svg'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {HighPriorityImage} from 'view/com/util/images/Image'
Expand Down Expand Up @@ -27,6 +27,7 @@ interface BaseUserAvatarProps {

interface UserAvatarProps extends BaseUserAvatarProps {
moderation?: ModerationUI
usePlainRNImage?: boolean
}

interface EditableUserAvatarProps extends BaseUserAvatarProps {
Expand Down Expand Up @@ -110,6 +111,7 @@ export function UserAvatar({
size,
avatar,
moderation,
usePlainRNImage = false,
}: UserAvatarProps) {
const pal = usePalette('default')

Expand Down Expand Up @@ -146,13 +148,24 @@ export function UserAvatar({
return avatar &&
!((moderation?.blur && isAndroid) /* android crashes with blur */) ? (
<View style={{width: size, height: size}}>
<HighPriorityImage
testID="userAvatarImage"
style={aviStyle}
contentFit="cover"
source={{uri: avatar}}
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
/>
{usePlainRNImage ? (
<Image
accessibilityIgnoresInvertColors
testID="userAvatarImage"
style={aviStyle}
resizeMode="cover"
source={{uri: avatar}}
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
/>
) : (
<HighPriorityImage
testID="userAvatarImage"
style={aviStyle}
contentFit="cover"
source={{uri: avatar}}
blurRadius={moderation?.blur ? BLUR_AMOUNT : 0}
/>
)}
{alert}
</View>
) : (
Expand Down
7 changes: 6 additions & 1 deletion src/view/shell/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ export const DrawerContent = observer(function DrawerContentImpl() {
accessibilityLabel="Profile"
accessibilityHint="Navigates to your profile"
onPress={onPressProfile}>
<UserAvatar size={80} avatar={store.me.avatar} />
<UserAvatar
size={80}
avatar={store.me.avatar}
// See https://github.com/bluesky-social/social-app/pull/1801:
usePlainRNImage={true}
/>
<Text
type="title-lg"
style={[pal.text, s.bold, styles.profileCardDisplayName]}
Expand Down
14 changes: 12 additions & 2 deletions src/view/shell/bottom-bar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,21 @@ export const BottomBar = observer(function BottomBarImpl({
styles.onProfile,
{borderColor: pal.text.color},
]}>
<UserAvatar avatar={store.me.avatar} size={27} />
<UserAvatar
avatar={store.me.avatar}
size={27}
// See https://github.com/bluesky-social/social-app/pull/1801:
usePlainRNImage={true}
/>
</View>
) : (
<View style={[styles.ctrlIcon, pal.text, styles.profileIcon]}>
<UserAvatar avatar={store.me.avatar} size={28} />
<UserAvatar
avatar={store.me.avatar}
size={28}
// See https://github.com/bluesky-social/social-app/pull/1801:
usePlainRNImage={true}
/>
</View>
)}
</View>
Expand Down

0 comments on commit 8747c21

Please sign in to comment.