-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Bug Report
Description
The PDF rendering process hangs indefinitely (infinite loop) when using the lineHeight property on a Text component within a flex container.
Environment
- @react-pdf/renderer version: 4.3.1
- Node.js version: v20.19.5
- Operating System: macOS
Reproduction
The following code causes the renderer to hang during PDF generation:
const styles = StyleSheet.create({
metricValueContainer: {
flexDirection: 'row',
alignItems: 'center',
},
metricValue: {
fontSize: 19.2,
color: '#333333',
lineHeight: 25.6, // This causes the hang
},
})
// Usage in component
<View style={styles.metricValueContainer}>
<Text style={styles.metricValue}>
{value}
</Text>
</View>Expected Behavior
The PDF should render successfully with the specified line height.
Actual Behavior
The process hangs indefinitely during PDF generation. No error is thrown, the process just never completes.
Workaround
Removing or commenting out the lineHeight property resolves the issue:
metricValue: {
fontSize: 19.2,
color: '#333333',
// lineHeight: 25.6, // Removed to prevent hang
},Additional Context
- The hang appears to be related to layout calculations in the yoga-layout engine
- The specific ratio between
fontSizeandlineHeightseems to trigger the issue - Other
lineHeightvalues in the same file (e.g.,lineHeight: 8.889) work fine - The issue occurs specifically when the Text is inside a flex container with
alignItems: 'center'
Possible Related Issues
This might be related to infinite layout recalculation loops when the layout engine tries to calculate text bounds with certain lineHeight values in flex contexts.
Would appreciate any insights or fixes for this issue!
Metadata
Metadata
Assignees
Labels
No labels