Font.loadAsync won't resolve, app stuck on SplashScreen forever

#1

Hi everyone,

I noticed this issue a few days ago when I saw in Google Analytics that new users weren’t triggering any events past the initial app load. It seems that on fresh installs,

await Font.loadAsync()

never resolves and so my app never loads past the splash screen.

I haven’t added or changed any fonts in the last few weeks but I did recently upgrade to SDK 29. I attempted to set assetBundlePatterns to include the fonts and avoid users needing to download them but Font.loadAsync() continues to never resolve.

Here’s my App.js:

class App extends React.Component {
  state = {
    fontLoaded: false,
  };

  componentWillMount() {
    this._loadFontsAsync();
  }

  async componentDidMount() {
    AppState.addEventListener('change', this.onAppStateChange);
  }


  onAppStateChange(appState) {
    if (appState === 'active') {
      analytics.event(new Event('Basic Usage', 'Open', 'App opened'));
    }
  }
  

  _loadFontsAsync = async () => {
    await Font.loadAsync({
      'open-sans-regular': require('./assets/fonts/OpenSans-Regular.ttf'),
      'open-sans-light': require('./assets/fonts/OpenSans-Light.ttf'),
      'raleway-regular': require('./assets/fonts/Raleway-Regular.ttf'),
      'raleway-medium': require('./assets/fonts/Raleway-Medium.ttf'),
      'raleway-light': require('./assets/fonts/Raleway-Light.ttf'),
      'raleway-semi-bold': require('./assets/fonts/Raleway-SemiBold.ttf'),
      'bebas-neue': require('./assets/fonts/BebasNeue.otf'),
      'avenir-demi': require('./assets/fonts/AvenirNextLTProDemi.ttf'),
      'avenir-medium': require('./assets/fonts/Avenir-Medium.ttf'),
      'custom-icon': require('./assets/fonts/customIcons/fontello.ttf'),
    });
    this.setState({ fontLoaded: true });
  };

  render() {
    const { isSignupSkipped, loggedInStatus } = this.props.appState.appUser;
    const { fontLoaded } = this.state;
    if (!fontLoaded) return <AppLoading autoHideSplash={false} />;
    if (loggedInStatus === 'Yes' || isSignupSkipped === true) {
      SplashScreen.hide();
      return (
        <View style={styles.appStyle}>
          <StatusBar translucent backgroundColor="grey" barStyle="light-content" animated />
          <TabView style={styles.mainView} />
        </View>
      );
    }
    if (loggedInStatus === 'No') {
      SplashScreen.hide();
      return (
        <View style={styles.appStyle}>
          <StatusBar translucent backgroundColor="grey" barStyle="light-content" animated />
          <AuthScreen />
        </View>
      );
    }
    return <AppLoading autoHideSplash={false} />;
  }
}

Any help would be greatly appreciated. It’s very frustrating for the app to be unusable to new users. Thanks!

closed #2

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.