react-native-qrcode-svg
react-native-qrcode-svg copied to clipboard
iOS crash when calling toDataURL too early after upgrading to Expo SDK 52
After upgrading to Expo SDK 52, calling toDataURL on the react-native-qrcode-svg component too early on iOS causes the app to crash. On Android no issue at all.
To work around this, we had to add a delay to ensure the QR code is fully rendered before calling toDataURL:
<QRCode
getRef={(c) => {
// Warning: Delay the call to toDataURL to ensure the QRCode has fully rendered.
// Without this delay, calling toDataURL too early on ios causes the app to crash.
setTimeout(() => {
c?.toDataURL((base64Image: string) => {
qrCodeImageUrl.current = base64Image;
});
}, Platform.OS === 'ios' ? 500 : 0);
}}
size={256}
value={link}
/>
This crash didn’t happen before upgrading to Expo 52.
Steps to Reproduce:
- Render a <QRCode /> component.
- Immediately call toDataURL() via getRef.
- Observe the crash on iOS.
Expected:
toDataURL() should work without crashing once the QR code is rendered.
Relevant Dependencies
{
"expo": "52.0.44",
"react-native": "0.76.9",
"react-native-qrcode-svg": "^6.3.15",
"react-native-svg": "15.11.2",
"expo-file-system": "18.0.12",
"expo-media-library": "17.0.6",
"expo-sharing": "13.0.1"
}