mxck / react-native-material-menu

Pure JavaScript material menu component for React Native
MIT License
520 stars 92 forks source link

iOS terminating due to uncaught exception of type NSException #126

Open dilipchandima opened 10 months ago

dilipchandima commented 10 months ago

This is the error log

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0.3333282470703125}, scale=3.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000011439f28d __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x000000010f547894 objc_exception_throw + 48
    2   Foundation                          0x0000000116a01e27 -[NSMutableDictionary(NSMutableDictionary) classForCoder] + 0
    3   UIKitCore                           0x000000012c397320 _UIGraphicsBeginImageContextWithOptions + 702
    4   Baas                                0x0000000101362a5b RCTUIGraphicsBeginImageContext + 139
    5   Baas                                0x000000010136115a RCTGetSolidBorderImage + 2234
    6   Baas                                0x00000001013607cb RCTGetBorderImage + 267
    7   Baas                                0x000000010145ecca -[RCTView displayLayer:] + 1306
    8   QuartzCore                          0x0000000111896bc8 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 472
    9   QuartzCore                          0x0000000111798464 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 706
    10  QuartzCore                          0x00000001117d29ba _ZN2CA11Transaction6commitEv + 728
    11  QuartzCore                          0x00000001117d3eaa _ZN2CA11Transaction25flush_as_runloop_observerEb + 60
    12  CoreFoundation                      0x00000001142fad94 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    13  CoreFoundation                      0x00000001142f572a __CFRunLoopDoObservers + 534
    14  CoreFoundation                      0x00000001142f5c72 __CFRunLoopRun + 1158
    15  CoreFoundation                      0x00000001142f5409 CFRunLoopRunSpecific + 557
    16  GraphicsServices                    0x00000001246ae187 GSEventRunModal + 137
    17  UIKitCore                           0x000000012c9973a2 -[UIApplication _run] + 972
    18  UIKitCore                           0x000000012c99be10 UIApplicationMain + 123
    19  Baas                                0x0000000100c72768 main + 104
    20  dyld                                0x000000010c2543ee start_sim + 10
    21  ???                                 0x00000002040ee3a6 0x0 + 8658019238
)
libc++abi: terminating due to uncaught exception of type NSException
richdacuban commented 9 months ago

@dilipchandima Facing this on a project where I have to maintain an older version of react native (0.63) that includes this package. This error is only appearing for us on REAL devices (not in simulator), running ios 17 (17.0.1); this is hard to reproduce. Any luck?

manimeik commented 6 months ago

got same issue on simulator. any solution?

mxck commented 6 months ago

Hello! I'm looking to archive this project as I haven't been actively working with react-native for a while now. I recommend using https://callstack.github.io/react-native-paper/docs/components/Menu/ for the menu. It was once based on my project some time ago.

haider792 commented 5 months ago

go to Menu Component in react native material menu, you will find this code,

react_native_1.Animated.timing(this.state.menuSizeAnimation, { toValue: { x: width, y: height }, duration: this.props.animationDuration, easing: EASING, useNativeDriver: false, }), react_native_1.Animated.timing(this.state.opacityAnimation, { toValue: 1, duration: this.props.animationDuration, easing: EASING, useNativeDriver: false, }),

replace it with

this.setState({ menuSizeAnimation: new react_native_1.Animated.ValueXY({ x: width, y: height }), opacityAnimation: new react_native_1.Animated.Value(1), })

        it will be resolved and working then
Usamah-crypto commented 3 months ago

Go to node_modules > react-native-material-menu > src > Menu.js: Replace the _onMenuLayout function with this :

_onMenuLayout = (e) => {
    if (this.state.menuState === STATES.ANIMATING) {
      return;
    }
    const { width, height } = e.nativeEvent.layout;
    this.setState(
      {
        menuState: STATES.ANIMATING,
        menuWidth: width,
        menuHeight: height,
      },
      () => {
        this.setState({
          menuSizeAnimation: new Animated.ValueXY({ x: width, y: height }),
          opacityAnimation: new Animated.Value(1),
          })
      },
    );
  };

Thanks @haider792 I have added more context to your comment.