Webview postMessage slow in Release/Production build
See original GitHub issue- I have reviewed the documentation
- I have searched existing issues
- I am using the latest React Native version
I’m using a webview to send click events back to react-native. When building for debug, the time to receive the message is quick ( 0.5 seconds), but when building for release/production the time is ~ 5 seconds in the simulator and ~10 seconds on device. I have also tried using react-native-wkwebview-reborn with the same result.
Environment
OS: OS X El Capitan 10.11.6 Node: 6.4.0 Yarn: Not Found npm: 3.10.3 Watchman: 4.6.0 Xcode: Xcode 8.0 Build version 8A218a Android Studio: 2.1 AI-143.3101438
Packages: (wanted => installed) react: 16.0.0 => 16.0.0 react-native: ^0.51.0 => 0.51.0
Steps to Reproduce
index.html
<script>
function sendMessage(){
window.postMessage('{"key":' + 1 +'}')
}
</script>
<body>
<button onclick='sendMessage()'>
Send
</button>
</body>
index.js
onWebViewMessage(event) {
console.log("Message received from webview", event);
}
....
<WebView
ref={webview => {
this.myWebView = webview;
}}
scrollEnabled={true}
source={require("./index.html")}
onMessage={this.onWebViewMessage}
style={{flex: 1}}
/>
Expected Behavior
Similar performance and speed to debug.
Actual Behavior
Much slower.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Is postMessage slow? - surma.dev
Queue a task in the receiving realm, that will execute the following steps: Run StructuredDeserialize() on the serialized message; Create a ...
Read more >react native html postMessage can not reach to WebView
Now I want to know: Is there better way to solve this problem? Why the delay 100 milliscond did not work, but delay...
Read more >169705 - WebWorker postMessage very slow when ... - Monorail
Sending the data to the web worker is unusually slow on Chrome, so that the browser becomes very unresponsive (it's actually slower then ......
Read more >Is postMessage slow? - HTTP 203 - YouTube
Jake and Surma look at workers and the performance of their messaging primitive postMessage ().Surma's blog post on the topic: ...
Read more >Window.postMessage() - Web APIs | MDN
The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I haven’t had the chance to update to Sierra/XCode9, running into the same issue here when building: https://github.com/facebook/react-native/issues/18238
Could someone try to reproduce in 0.54?
Edit: Got it running in 0.53, same behaviour though.
Hi, just want to let you know that I’m having the same issue.
Fetching data from the server goes fast (<1s) when running in debug mode with Remote JS Debugging enabled. If Remote debugging is disabled or running the release version, the same action takes >10s.
Using “react-native”: “0.55.4”
I don’t know if it’s related to this issue, but I’m using “cross-fetch”: “^2.2.0” to fetch data.
It would be great if anyone knows how to solve this… Thanks.
EDIT: The problem was related to something else. There was still some logging enabled in the release version which caused the performance hit. Without logging, everything runs silky smooth…