react-native-ui-kitten: On iOS app crashes with the message "Got unexpected undefined"
š Bug Report
The bug seems to occur only on iOS on one app of mine with a very confusing behavior.
To Reproduce
Steps to reproduce the behavior: On my app:
- navigate to a screen containing a Select component ;
- open the Select popover (no need to select another item) ;
- navigate to next screen ;
- go back to first screen.
App crashes in release mode / Red screens in debug mode with the message āGot unexpected undefinedā pointing to measureSelf function in ānode_modules/@ui-kitten/components/devsupport/components/measure/measure.component.jsā.
If you donāt open the Select popover there is no crash.
A quick session with Flipper shows that measureSelf passes ānullā in the ānodeā variable. It seems to be a problem about the Select component keeping reacting to system events after being unmountedā¦ Adding a setTimeout() does not solve anything. Iām fixing it with a patch adding a null check on the node variable before calling measureInWindow(). Iāll work on a repro and a PR as soon as possible.
Expected behavior
App doesnāt crash š
Link to runnable example or repository (highly encouraged)
Iāll try to take time to produce one later.
UI Kitten and Eva version
Package | Version |
---|---|
@eva-design/eva | 2.1.1 |
@ui-kitten/components | 5.1.2 |
Environment information
OS: macOS 13.5.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.19.4 - ~/Sources/Adoria/adoria-start/node_modules/.bin/npm
pnpm: 8.9.0 - /usr/local/bin/pnpm
Watchman: 2023.08.28.00 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.10121639
Xcode: 15.0/15A240d - /usr/bin/xcodebuild
npmPackages:
react: 18.2.0 => 18.2.0
react-native: 0.72.5 => 0.72.5
About this issue
- Original URL
- State: open
- Created 9 months ago
- Reactions: 14
- Comments: 26 (1 by maintainers)
Commits related to this issue
- Measure a node only if it has been found, fixes issue #1782 — committed to psegalen/react-native-ui-kitten by psegalen 8 months ago
For those using yarn patch or patch-package, hereās the patch Iām using:
Experiencing the same issue with 5.3.1, it happens some time between navigations but not every time, really hard to narrow down whatās really happening š¤
The solution is in measure.component.js to check for if (node):
However, I guess either a new release is needed or a patch, but not too confident
@GoDeepBlue you can patch UI Kitten with the code from my PR as a temporary solution until the PR is merged. For this specific problem, the fix is at line 78 in https://github.com/akveo/react-native-ui-kitten/pull/1790/files I have 2 apps on which this patch prevented the crash to be reported by crashlytics and sentry, one is patched with patch-package because itās a Yarn 1.x project, the other with yarn patch, both are ok now
Hey @psegalen thanks for your advise and reply!
Hi @adrianlzx1996 and @brunomartins-com ! First of all: donāt just edit directly the source files in node_modules because each time youāll do a dependencies install (through npm or yarn), your edition will be deleted. You need to create a patch, there are basically 2 ways to do that and it depends if you use yarn 2+ or not. For yarn 2+ you can use the built-in feature yarn patch, doc is there: https://yarnpkg.com/cli/patch For yarn 1.x or npm, you can use the āpatch-packageā devDependency, here is tutorial: https://dev.to/zhnedyalkow/the-easiest-way-to-patch-your-npm-package-4ece Anyway, for both tools the procedure is the same: once the tool is operational make your edition to the source code of your dependency in node_modules and launch the patch procedure, it will generate a patch (a file telling your dependencies manager that it needs to modify one dependency after its install and how to modify it)
Thank you @psegalen, I implemented the fix and seems to be working so far! You areš„ š
I am receiving the same issue. Version is js on ā@ui-kitten/componentsā: ā^5.3.1ā and āreact-nativeā: ā^0.73.1ā
Issue occurs while navigating between screens and I have spent a ton of time trying to narrow down the bug. š
Basically produces: ERROR Error: Got unexpected undefined, js engine: hermes
Then trace gets to: ā¦/node_modules/@ui-kitten/components/devsupport/components/measure/measure.component.js with code error spawn code ENOENT
Any help or workarounds? I am stuck š¦