react-native-qrcode-svg icon indicating copy to clipboard operation
react-native-qrcode-svg copied to clipboard

iOS crash when calling toDataURL too early after upgrading to Expo SDK 52

Open kevmmdev opened this issue 1 year ago • 0 comments

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:

  1. Render a <QRCode /> component.
  2. Immediately call toDataURL() via getRef.
  3. 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"
}

kevmmdev avatar Apr 09 '25 09:04 kevmmdev