Open emitchel opened 7 years ago
@emitchel, I've seen a lot of people doing intensive work and it blocks the UI thread. one fix could be moving var message = receiveQueue.pop();
out side of setTimeout
function which fix your problem. we might even use setImmediate
instead of setTimeout
to reduce the delay, but I would prefer to make this call async so I can return the thread back to the poll as fast as possible.
Do you think one of the above solutions might fix or help your problem?
@alinz I believe moving the .pop()
outside of the timeout should be sufficient. Thanks for the response!
https://github.com/alinz/react-native-webview-bridge/blob/master/scripts/webviewbridge.js#L37
This line shows we're arbitrarily delaying the message sent by 15ms. In my scenario I have call A which finishes almost instantly and call A pushes message X to the webview, call B depends on data from call A and pushes message Y to the webview. By the time 15ms is over, the list (named queue but is actually a stack implementation) of 2 messages (X and Y) is called in reverse because it's
pop()
ing the list. I could work (am currently) around this but I feel we shouldn't pop from the list if we're going to have a delay, or we shouldn't have a delay at all.Thoughts?