react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

UIImage imageWithSize (UIGraphicsBeginImageContext) causing crash on iOS 17 (XCode 15)

Open OskarEichler opened this issue 2 years ago • 4 comments

What happened?

On the latest version of react-native-navigation and react-native, when we are trying to run our app on iOS 17, we are receiving the following main thread crash:

Exception	NSException *	"UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={1, 0}, scale=1.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert."	0x0000600000d35170

It seems to be cause by UIGraphicsBeginImageContext(size); inside the imageWithSize method in UIImage+utils.m

When commenting out the line it works. I assume it's because it's passing the height as 0, but not sure where this is coming from as the stack-trace is incomplete. This should definitely be handled.

Potentially some more useful information here: https://developer.apple.com/forums/thread/733326

What was the expected behaviour?

No response

Was it tested on latest react-native-navigation?

  • [X] I have tested this issue on the latest react-native-navigation release and it still reproduces.

Help us reproduce this issue!

No response

In what environment did this happen?

React Native Navigation version: 7.37.0-hotfix.1 React Native version: 0.72.5 Has Fabric (React Native's new rendering system) enabled: no Device model: iPhone 15 Pro iOS version: 17.0

OskarEichler avatar Sep 25 '23 12:09 OskarEichler

It seems to happen when we set

  bottomTabs: {
    backgroundColor: globalStyles.colors.base,
    borderColor: globalStyles.colors.gray2,
    borderWidth: Platform.OS === 'ios' ? 0 : 1,
  },

Setting it to 0 or to null both causes the crash... - setting it to undefined fixed it.

Would still be good to handle the 0 case.

OskarEichler avatar Sep 25 '23 12:09 OskarEichler

@OskarEichler you are a live saver! And indeed, it should accept 0 or even null

vincentzierigen avatar Sep 26 '23 21:09 vincentzierigen

Anyone able to solve this? Setting the options did not solve it for me.

Edit: Solved by setting the following:

Navigation.setDefaultOptions({
  bottomTabs: {
          borderWidth: undefined,
      }
})

Before i had Platform.OS === 'ios' ? 0 : 1 for theborderWidth. Should support null or 0

Spxc avatar Nov 12 '23 13:11 Spxc

in my case it happened when tintColor was passed in FastImage <FastImage tintColor={'#000000'} style={styles.iconStyle1} source={require('../../assets/close.png')} />

this fixed the issue <Image style={[styles.iconStyle1, { tintColor: '#000000' }]} source={require('../../assets/close.png')} />

AJV2018 avatar Jul 20 '24 09:07 AJV2018