You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Underlying WKWebView instance is not disposed of after unmounting WebView component #22067
When the useWebKit prop is set on the WebView component the underlying WKWebView instance does not get disposed of after the component is unmounted. These lingering instances can be seen using the Develop menu in Safari. This is only a problem when the useWebKit prop is set.
Reproducible Demo
Run the following code using react-native run-ios from the repository or by copy/pasting into App.js in a newly initialized React Native project.
Launch Safari and verify that you can see JSContext running in the simulator.
Click the 'Toggle WebView' button to mount and unmount the WebView component.
Verify that the unmounted WKWebView instances are still active and accessible via Safari.
Remove the useWebKit prop and re-run to verify this only happens when that prop is set.
Have you tried this with the separate react-native-webview ? It looks like that's where more improvements for the Webview component land (faster) and the current one will be removed from the core at some point, according to this approved proposal. You can see the full discussion here.
@bartolkaruza Thank you for bringing this to my attention. I had fallen back to using https://github.com/CRAlpha/react-native-wkwebview since there was no mention of the separate WebView package in the docs. I just tested it and the separate react-native-webview disposes of the WebView instances properly so it's just an issue with the built-in component.
I feel like this issue should still be left open though since this seems like a pretty serious memory leak and there isn't any indication from the docs or console output that the built-in WebView component shouldn't be used.
Activity
bartolkaruza commentedon Nov 2, 2018
Have you tried this with the separate react-native-webview ? It looks like that's where more improvements for the Webview component land (faster) and the current one will be removed from the core at some point, according to this approved proposal. You can see the full discussion here.
jacamera commentedon Nov 2, 2018
@bartolkaruza Thank you for bringing this to my attention. I had fallen back to using https://github.com/CRAlpha/react-native-wkwebview since there was no mention of the separate WebView package in the docs. I just tested it and the separate react-native-webview disposes of the WebView instances properly so it's just an issue with the built-in component.
I feel like this issue should still be left open though since this seems like a pretty serious memory leak and there isn't any indication from the docs or console output that the built-in WebView component shouldn't be used.
hramos commentedon Nov 30, 2018
Please file an issue over at https://github.com/react-native-community/react-native-webview. The webview in this repository will be removed in a future version, and no WebView PRs are being merged on this repository.