我的 React Native 应用程序遇到随机崩溃,我无法一致地重现。我已经集成了 Sentry 和 Firebase Crashlytics,但都没有捕获这些崩溃。该问题发生在多个设备上。与 Android 相比,iOS 中的比率更高。但总体来说这个问题的复现率很低,而且没有步骤。我们的应用程序包含以下功能。
当应用程序在调试时崩溃时,我从 XCode 中收到一个有关崩溃的弹出窗口,其屏幕截图如下所示
添加了react-native-exception-handler,但无法捕获任何问题。虽然我尝试在调试模式下手动崩溃它,但效果很好。
我们使用react-native-blob-util在应用程序中缓存图像。我尝试禁用图像缓存逻辑以查看该库是否导致任何问题。
集成了 Sentry 和 Firebase Crashlytics 以查看问题是否记录在那里。但那里没有报告有关这些随机崩溃的问题。
尝试删除 Sentry(配置和实现)以查看哨兵是否导致任何问题。
尝试进行 http 调用而不是 https 调用来检查 NSAllowsArbitraryLoads(在我们的应用程序中设置为 false)是否导致任何问题
从开发者菜单 > 性能监视器监控 RAM 使用情况,其中我们的应用程序在满负载时使用的最大 RAM 高达 820mbs。我们尝试通过频繁调用多个 API、在屏幕之间随机切换以及启动音频视频通话和消息传递来满负载使用该应用程序。这是package.json
{
"name": "exampleApp",
"version": "4.8.22",
"private": true,
"scripts": {
"build:android:bundle": "cd android && ./gradlew bundleRelease && cd ..",
"build:android:release": "cd android && ./gradlew app:assembleRelease && cd ..",
"clean:android": "cd android && ./gradlew clean && cd ../",
"cra": "yarn clean:android && yarn run:android",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"lint-staged": "lint-staged --config lint-staged.js",
"pod:install": "cd ios && pod install && cd ..",
"pod:remove": "cd ios && pod deintegrate && cd ..",
"postinstall": "patch-package",
"prepare": "husky install",
"prettier": "prettier src -check",
"run:android": "react-native run-android",
"run:ios": "react-native run-ios",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@bam.tech/react-native-image-resizer": "^3.0.7",
"@gorhom/bottom-sheet": "^4.6.1",
"@ptomasroos/react-native-multi-slider": "^2.2.2",
"@react-native-async-storage/async-storage": "^1.21.0",
"@react-native-clipboard/clipboard": "^1.14.2",
"@react-native-community/datetimepicker": "^7.6.2",
"@react-native-community/netinfo": "^11.3.2",
"@react-native-community/push-notification-ios": "^1.11.0",
"@react-native-community/slider": "^4.5.0",
"@react-native-firebase/analytics": "^20.0.0",
"@react-native-firebase/app": "^20.0.0",
"@react-native-firebase/crashlytics": "^20.0.0",
"@react-native-masked-view/masked-view": "^0.3.1",
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"@react-navigation/stack": "^6.3.20",
"@reduxjs/toolkit": "^2.0.1",
"@zoom/react-native-videosdk": "^1.11.0",
"card-validator": "^9.1.0",
"date-fns": "^3.3.1",
"html-parse-stringify": "^3.0.1",
"moment": "^2.30.1",
"moment-timezone": "^0.5.45",
"native-base": "^3.4.28",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"query-string": "^9.0.0",
"react": "18.2.0",
"react-hook-form": "^7.50.1",
"react-native": "0.74.6",
"react-native-agora": "^4.3.2",
"react-native-animatable": "^1.4.0",
"react-native-app-intro-slider": "^4.0.4",
"react-native-appsflyer": "^6.14.3",
"react-native-audio": "^4.3.0",
"react-native-autolink": "^4.2.0",
"react-native-blob-util": "^0.19.11",
"react-native-calendars": "1.1304.1",
"react-native-confirmation-code-field": "^7.3.2",
"react-native-country-codes-picker": "^2.3.5",
"react-native-date-picker": "^4.3.7",
"react-native-device-info": "^10.12.0",
"react-native-document-picker": "^9.1.1",
"react-native-fast-image": "^8.6.3",
"react-native-floating-label-input": "^1.4.3",
"react-native-gesture-handler": "^2.15.0",
"react-native-gifted-chat": "2.4.0",
"react-native-i18n": "^2.0.15",
"react-native-image-crop-picker": "^0.41.2",
"react-native-image-picker": "^7.1.2",
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-in-app-review": "^4.3.3",
"react-native-keep-awake": "^4.0.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-linear-gradient": "^2.8.3",
"react-native-onesignal": "^5.2.2",
"react-native-permissions": "^4.1.5",
"react-native-push-notification": "^8.1.1",
"react-native-qrcode-svg": "^6.3.1",
"react-native-ratings": "^8.1.0",
"react-native-reanimated": "3.15.0",
"react-native-render-html": "^6.3.4",
"react-native-restart": "^0.0.27",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "^3.29.0",
"react-native-scroll-picker-wheel": "^1.0.2",
"react-native-share": "^10.1.0",
"react-native-size-matters": "^0.4.2",
"react-native-skeleton-placeholder": "^5.2.4",
"react-native-sms-retriever": "^1.1.1",
"react-native-sound": "^0.11.2",
"react-native-svg": "^14.1.0",
"react-native-switch-selector": "^2.3.0",
"react-native-tracking-transparency": "^0.1.2",
"react-native-vector-icons": "^10.0.3",
"react-native-version-check": "^3.4.7",
"react-native-webview": "^13.8.6",
"react-redux": "^9.0.4",
"socket.io-client": "^4.7.5",
"tabby-react-native-sdk": "^1.3.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.74.88",
"@react-native/eslint-config": "0.74.88",
"@react-native/metro-config": "0.74.88",
"@react-native/typescript-config": "0.74.88",
"@types/axios": "^0.14.0",
"@types/react": "^18.2.6",
"@types/react-native-i18n": "^2.0.2",
"@types/react-native-push-notification": "^8.1.4",
"@types/react-native-vector-icons": "^6.4.18",
"@types/react-native-version-check": "^3.4.8",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"babel-jest": "^29.6.3",
"eslint": "^8.56.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.1.0",
"husky": "^8.0.3",
"jest": "^29.6.3",
"lint-staged": "^15.2.0",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"tsc-files": "^1.1.4",
"typescript": "5.0.4"
},
"engines": {
"node": ">=18"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
你可以尝试使用 android studio logcat 进行测试,也许你可以捕获致命错误并解决它