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

getting crash on iOS 15

Open San10694 opened this issue 3 years ago • 15 comments

NSInvalidArgumentExceptionRNSnackBarView.m:184 Unable to parse constraint format: Unable to interpret '|' character, because the related view doesn't have a superview V:[self(>=48)]| ^

we are getting this exception for only iOS 15 and above iPhone's users Please suggest how to fix the issue

"name": "react-native-snackbar", "version": "2.2.0",

San10694 avatar Sep 30 '21 05:09 San10694

Do you have try with version 2.4 of react-native-snackbar ?

rvasseur31 avatar Oct 06 '21 07:10 rvasseur31

@rvasseur31 yes using that only "react-native-snackbar": "2.4.0", our iOS app crash rate suddenly increased to 100% just because of this exception Please help

San10694 avatar Oct 07 '21 05:10 San10694

we have the same issue happens with devices where IOS version is 15.0.1 and the "react-native-snackbar": "^2.4.0",

Fatal Exception: NSInvalidArgumentException
Unable to parse constraint format: Unable to interpret '|' character, because the related view doesn't have a superview V:[self(>=48)]| ^

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x9905c __exceptionPreprocess
1  libobjc.A.dylib                0x15f54 objc_exception_throw
2  CoreAutoLayout                 0x32aec -[NSLayoutConstraintParser metricForKey:]
3  CoreAutoLayout                 0x4744 -[NSLayoutConstraintParser finishConstraint]
4  CoreAutoLayout                 0x37a0 -[NSLayoutConstraintParser parse]
5  CoreAutoLayout                 0xb230 +[NSLayoutConstraintParser constraintsWithVisualFormat:options:metrics:views:]
6  AppName                        0x2b245c -[RNSnackBarView presentWithDuration:] + 188 (RNSnackBarView.m:188)
7  AppName                        0x2b2e90 -[RNSnackBarView show] + 284 (RNSnackBarView.m:284)
8  UIKitCore                      0x2c638c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:]
9  UIKitCore                      0x190b3c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
10 UIKitCore                      0x1a5208 -[UIViewAnimationState animationDidStop:finished:]
11 QuartzCore                     0xc8a9c CA::Layer::run_animation_callbacks(void*)
12 libdispatch.dylib              0x3950 _dispatch_client_callout
13 libdispatch.dylib              0x11d30 _dispatch_main_queue_callback_4CF
14 CoreFoundation                 0x51ce4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
15 CoreFoundation                 0xbebc __CFRunLoopRun
16 CoreFoundation                 0x1f3c8 CFRunLoopRunSpecific
17 GraphicsServices               0x138c GSEventRunModal
18 UIKitCore                      0x51b0bc -[UIApplication _run]
19 UIKitCore                      0x298be8 UIApplicationMain
20 AppName                        0x63c4 main + 7 (main.m:7)
21 ???                            0x105b05a24 (Missing)

mouessam avatar Oct 11 '21 09:10 mouessam

I don't know about native iOS development and if these screenshots will help, but this is the bug report we got. NOTE: I was unable to reproduce it on iOS 15.0.2

image

This is the part where crashed

image

PauloMello99 avatar Oct 19 '21 12:10 PauloMello99

@PauloMello99 that's the issue, even I am unable to reproduce it, just getting crash logs for other users

San10694 avatar Oct 19 '21 13:10 San10694

Any update on this issue?

shahnewaz469 avatar Nov 29 '21 12:11 shahnewaz469

@rvasseur31 and the community can we please look inti this crash , this crash had increased our total crash rate, seems very critical. Thank you in advance

San10694 avatar Dec 03 '21 07:12 San10694

I would like to know if the crash occurred every times ? I use my fork and i don't have crash on ios 15, it implement native events on snackbar visibility, if you want to learn more : https://github.com/rvasseur31/react-native-snackbar/tree/feature/callbacks#advanced-usage

in my package.json i use : "react-native-snackbar": "rvasseur31/react-native-snackbar#feature/callbacks".

EDIT : I forgot, i also add this in my package.json to build install the dependencies : "build-snackbar": "cd ./node_modules/react-native-snackbar && yarn && rm -rf node_modules example", "postinstall": "yarn build-snackbar"

Can you please tell me if the crash occurred ? And can you provide react native info with : npx react-native info ?

rvasseur31 avatar Dec 07 '21 10:12 rvasseur31

this is a pain for ios users - I'm seeing > 100 new crashes.

when this exception is thrown - maybe we can simply wrap it in a try catch ? DRAFTED FIX - https://github.com/cooperka/react-native-snackbar/pull/196

WORK IN PROGRESS (untested)

 npm uninstall react-native-snackbar
 yarn  add git+https://github.com/pe-johndpope/react-native-snackbar.git
 npx pod-install

UPDATE

hitting a wall with this error


ror While trying to resolve module `react-native-snackbar` from file `/Users/johndpope/Documents/gitWorkspace/customerpoolapp/src/utils/SnackbarHandler.ts`, the package `/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/lib/index.js`. Indeed, none of these files exist:

  * /Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/lib/index.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * /Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/lib/index.js/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx).
Error: While trying to resolve module `react-native-snackbar` from file `/Users/johndpope/Documents/gitWorkspace/customerpoolapp/src/utils/SnackbarHandler.ts`, the package `/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/lib/index.js`. Indeed, none of these files exist:

  * /Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/lib/index.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * /Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/react-native-snackbar/lib/index.js/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
    at DependencyGraph.resolveDependency (/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/metro/src/node-haste/DependencyGraph.js:311:17)
    at Object.resolve (/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/metro/src/lib/transformHelpers.js:129:24)
    at resolve (/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
    at /Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
    at processModule (/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async addDependency (/Users/johndpope/Documents/gitWorkspace/customerpoolapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
    at async Promise.all (index 5)

pe-johndpope avatar Apr 19 '22 02:04 pe-johndpope

hi @pe-johndpope, in order to use your snackbar fork you'll need to compile and commit the lib directory of this library. you can do that by editing .gitignore, running yarn run build, and committing lib. let me know if that works for you!

as noted on your PR, I can't accept the change as-is, but if the change is acceptable to your own app, would you be willing to deploy something like this (maybe add more logging at different points to output what's going on at the time of the crash) and report back about what kind of devices are encountering the issue and help get us closer to the root causes?

as an open-source developer, I don't have access to the rich crash data that folks are referring to in the comments, so there's not much I can do as a maintainer until someone figures out what's causing the crash.

cooperka avatar Apr 19 '22 21:04 cooperka

I resolved the missing lib- thx. I’m still testing this.

UPDATE Crashes are gone with this fix.

I suspect this is occurring with view controllers that’s been or being popped. (Your specific edge case where you want to fail hard if there’s button on snack bar you could test for. If there’s no button then don’t crash. Keep in mind that majority of people won’t have this setup and the crash is impacting lots of users.) I’ve submitted app to apple for review will keep you posted on future crashes. objective c land can also test for superview quite simply. The actual root cause is the UIKit view is looking to apply a constraint on a view that doesn’t have a superview. Ie - it’s orphaned.

johndpope avatar Apr 19 '22 22:04 johndpope

I resolved the missing lib- thx. I’m still testing this.

UPDATE Crashes are gone with this fix.

I suspect this is occurring with view controllers that’s been or being popped. (Your specific edge case where you want to fail hard if there’s button on snack bar you could test for. If there’s no button then don’t crash. Keep in mind that majority of people won’t have this setup and the crash is impacting lots of users.) I’ve submitted app to apple for review will keep you posted on future crashes. objective c land can also test for superview quite simply. The actual root cause is the UIKit view is looking to apply a constraint on a view that doesn’t have a superview. Ie - it’s orphaned.

I am receiving the crash reports as well but I couldn't reproduce it from simulators or devices with iOS 15, with or without action button.

Can anyone reproduce the crash?

tarouboy avatar Jun 10 '22 11:06 tarouboy

this branch is working for me -

 npm uninstall react-native-snackbar
 yarn  add git+https://github.com/pe-johndpope/react-native-snackbar.git
 npx pod-install

I saw this the other day - maybe nice alternative https://docs.nativebase.io/toast

johndpope avatar Jun 12 '22 23:06 johndpope

@cooperka current the lib access UIWindow access by UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; and was deprecated in ios 15 can return nil https://developer.apple.com/forums/thread/695932 and when I debugged this and passed UIWindow *keyWindow = nil; it threw the exact error Unable to parse constraint format: Unable to interpret '|' character, because the related view doesn't have a superview V:[self(>=48)]| ^

what if we replace accessing UIWindow by UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window; which would point to window of AppDelegagte

I am not expert on IOS but trying to fix this

AdityaPahilwani avatar Sep 13 '22 18:09 AdityaPahilwani

Can you try this? I pushed to my main fork - (hopefully doesn't break things) UIWindow* keyWindow = [[[UIApplication sharedApplication] windows] lastObject];

 npm uninstall react-native-snackbar
 yarn  add git+https://github.com/pe-johndpope/react-native-snackbar.git
 npx pod-install

johndpope avatar Sep 13 '22 23:09 johndpope

@johndpope we managed to solve the issue by accessing the UIWindow by UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;

Opened a PR for the same https://github.com/cooperka/react-native-snackbar/pull/198

AdityaPahilwani avatar Oct 08 '22 08:10 AdityaPahilwani

fix released in v2.5.0, thanks all!

cooperka avatar May 09 '23 14:05 cooperka