react-native-vector-icons: iOS + Hermes, Error: Font failed to load (generatorResume)
- Review the documentation: https://github.com/oblador/react-native-vector-icons
- Search for existing issues (including closed issues): https://github.com/oblador/react-native-vector-icons/issues
Environment
iOS 16 “react-native-vector-icons”: “9.2.0”, react-native: 0.70.3
Description
When building an iOS version with Hermes enable, the app crashers at startup:
Error: Font failed to load
at apply(node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:105:55)
at ? (node_modules/react-native-vector-icons/lib/create-icon-set.js:175:13)
at generatorResume([native code])
at asyncGeneratorStep(node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:20)
at _next(node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
at fn(node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7)
at tryCallTwo(node_modules/promise/setimmediate/core.js:45:5)
at doResolve(node_modules/promise/setimmediate/core.js:200:13)
at Promise(node_modules/promise/setimmediate/core.js:66:3)
at apply(node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:16)
at _loadFont(node_modules/react-native-vector-icons/lib/create-icon-set.js:26:3)
at loadFont(node_modules/react-native-vector-icons/lib/create-icon-set.js:26:3)
at ? (src/App.js:312:12)
at generatorResume([native code])
at asyncGeneratorStep(node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:20)
at _next(node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
at fn(node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7)
at tryCallTwo(node_modules/promise/setimmediate/core.js:45:5)
at doResolve(node_modules/promise/setimmediate/core.js:200:13)
at Promise(node_modules/promise/setimmediate/core.js:66:3)
at apply(node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:16)
at _init(src/App.js:100:21)
at init(src/App.js:100:21)
at ? (src/App.js:622:11)
at generatorResume([native code])
at asyncGeneratorStep(node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:20)
at _next(node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
at fn(node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7)
at tryCallTwo(node_modules/promise/setimmediate/core.js:45:5)
at doResolve(node_modules/promise/setimmediate/core.js:200:13)
at Promise(node_modules/promise/setimmediate/core.js:66:3)
at apply(node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:16)
at _componentDidMountAsync(src/App.js:100:21)
at componentDidMountAsync(src/App.js:100:21)
at create$73(src/App.js:143:5)
at commitHookEffectListMount(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:5828:26)
at flushPassiveEffects(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7532:23)
at d(node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7371:7)
at J(node_modules/scheduler/cjs/scheduler.production.min.js:13:203)
at R(node_modules/scheduler/cjs/scheduler.production.min.js:14:128)
at callback(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:248:18)
at _callTimer(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:112:7)
at _callReactNativeMicrotasksPass(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:162:5)
at _reactNativeMicrotasksCallback(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:413:12)
at __callReactNativeMicrotasks(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:390:12)
at fn(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:132:12)
at __guard(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:367:9)
at value(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:131:10)
at value([native code])
at value([native code])
Reproducible Demo
Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve
import Icon from 'react-native-vector-icons/FontAwesome';
import EntypoIcon from 'react-native-vector-icons/Entypo';
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 16 (1 by maintainers)
@tsukudabuddha 's solution worked for me:
You can use this workaround to suppress the warnings:
Instead of having the useless warning in the yellow box, it will now print it to the console only. The icons still load fine with this.
I have the same issue, but I’m not using hermes.
WARN Possible Unhandled Promise Rejection (id: 0): Error: Font failed to load
I did some debugging and it looks like the error occurs when trying to register the font (triggered by
loadFont). The error iserror __NSCFError * domain: @"com.apple.CoreText.CTFontManagerErrorDomain" - code: 305 0x0000600002a667c0. Not sure why this is happening, but considering the images are still working I think it would be fine to add|| kCTFontManagerErrorDuplicatedNameto the conditional onl:166ofRNVectorIconsManageras a short term fix for nowI can confirm the same behavior. The error is only present on iOS 16+, but the font icons work in spite of the error.
react-native-vector-icons:9.2.0react:18.1.0react-native:0.70.6Creating a patch file with the above changes worked for my project, thanks!