[Unhandled promise rejection: Error: The WKWebView was invalidated]

Getting the following warning every time I open my app: [Unhandled promise rejection: Error: The WKWebView was invalidated]

Env:
{
“dependencies”: {
@expo/vector-icons”: “^10.0.0”,
“apisauce”: “^0.14.3”,
“big-js”: “^3.1.3”,
“eslint-config-prettier”: “^3.3.0”,
“eslint-plugin-prettier”: “^3.0.0”,
“expo”: “^33.0.7”,
“expo-analytics”: “^1.0.9”,
“expo-asset”: “^5.0.1”,
“expo-cli”: “^2.20.0”,
“expo-constants”: “^5.0.1”,
“expo-font”: “^5.0.1”,
“expo-web-browser”: “^5.0.3”,
“format-json”: “^1.0.3”,
“glamorous-native”: “^1.4.0”,
“global”: “^4.4.0”,
“i18n-js”: “^3.2.2”,
“identity-obj-proxy”: “^3.0.0”,
“jwt-decode”: “^2.2.0”,
“lodash”: “^4.17.4”,
“lottie-react-native”: “^2.6.1”,
“moment”: “^2.23.0”,
“moment-timezone”: “^0.5.25”,
“numbro”: “^2.1.2”,
“prop-types”: “^15.6.0”,
“qrcode.react”: “^0.9.2”,
“querystringify”: “1.0.0”,
“ramda”: “^0.25.0”,
“react”: “16.8.3”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz”,
“react-native-animatable”: “^1.3.0”,
“react-native-chart-kit”: “github:okasato/react-native-chart-kit”,
“react-native-country-picker-modal”: “^0.6.2”,
“react-native-datepicker”: “^1.7.2”,
“react-native-elements”: “^1.1.0”,
“react-native-form”: “^2.1.3”,
“react-native-i18n”: “^2.0.14”,
“react-native-keyboard-aware-scroll-view”: “^0.8.0”,
“react-native-keyboard-spacer”: “^0.4.1”,
“react-native-loading-spinner-overlay”: “^1.0.1”,
“react-native-picker-select”: “^6.1.0”,
“react-native-progress-bar-animated”: “^1.0.6”,
“react-native-qrcode”: “^0.2.7”,
“react-native-svg”: “^9.4.0”,
“react-native-webview”: “^5.8.1”,
“react-navigation”: “^2.18.2”,
“react-redux”: “^5.0.6”,
“react-sparklines”: “^1.7.0”,
“redux”: “^3.7.2”,
“redux-persist”: “^5.10.0”,
“redux-persist-transform-filter”: “0.0.18”,
“redux-saga”: “^0.16.0”,
“reduxsauce”: “0.7.0”,
“seamless-immutable”: “^7.1.4”,
“sentry-expo”: “~1.13.0”,
“socket.io-client”: “^2.2.0”,
“victory-native”: “^31.0.0”
},
“devDependencies”: {
@babel/core”: “^7.2.2”,
@babel/plugin-proposal-class-properties”: “^7.3.4”,
@babel/plugin-transform-modules-commonjs”: “^7.2.0”,
@storybook/addon-storyshots”: “^3.2.16”,
@storybook/addons”: “^3.2.16”,
@storybook/channels”: “^3.2.16”,
@storybook/react-native”: “^3.2.16”,
“babel-core”: “^7.0.0-bridge.0”,
“babel-eslint”: “^7.2.3”,
“babel-jest”: “^23.6.0”,
“babel-plugin-ignite-ignore-reactotron”: “^0.3.0”,
“babel-plugin-module-resolver”: “^3.2.0”,
“babel-plugin-transform-remove-console”: “^6.9.4”,
“babel-preset-env”: “^1.7.0”,
“babel-preset-expo”: “^5.0.0”,
“enzyme”: “^3.3.0”,
“enzyme-adapter-react-16”: “^1.1.0”,
“eslint-config-airbnb”: “^17.1.0”,
“eslint-plugin-jsx-a11y”: “^6.1.2”,
“husky”: “^0.14.3”,
“ignite-animatable”: “^1.0.2”,
“ignite-expo”: “^0.30.0”,
“ignite-i18n”: “^1.2.0”,
“ignite-redux-persist”: “^1.1.0”,
“ignite-standard”: “^1.0.0”,
“jest”: “23.6.0”,
“jest-expo”: “^33.0.0”,
“metro-react-native-babel-preset”: “^0.51.1”,
“mockery”: “^2.1.0”,
“react-addons-test-utils”: “^15.6.2”,
“react-dom”: “^16.2.0”,
“react-native-scripts”: “1.10.0”,
“react-test-renderer”: “16.3.1”,
“reactotron-react-native”: “^2.1.0”,
“reactotron-redux”: “^2.1.0”,
“reactotron-redux-saga”: “^2.1.0”,
“redux-mock-store”: “^1.5.3”,
“snazzy”: “^8.0.0”,
“standard”: “^10.0.2”
},
}

same here, its happens only on iOS, after upgrading to sdk 33

I was getting this error when creating more than one instance of expo analytics. I fixed it by creating a single instance and passing it through to the rest of my components using context.

In my App.js:
const analytics = new Analytics(AppConfig.googleAnalyticsKey);

In my other components, I used a consumer to retrieve the analytics:
const RootContainer = props => ( <Context.Consumer> {context => ( <ConnectedRootContainer {...props} analytics={context.analytics} /> )} </Context.Consumer> );

Expo-analytics calls getWebbviewUserAgentAsync from expo-constants. This can cause the KWebView was invalidated error (only on iOS) especially if new Analytics is called multiple times. I made a pull request for expo-analytics caching the userAgent and give the ability to use a static user agent: const analytics = new Analytics('UA-XXXXXX-Y', null, { userAgent: 'Custom UserAgent' }); Pull Request: User agent caching and static option. by musemind · Pull Request #45 · betaacid/expo-analytics · GitHub

7 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.