-
-
Notifications
You must be signed in to change notification settings - Fork 675
Description
We are using postMessage to communicate between react app and message list (i.e WebView).
postMessage is acting as a bridge between whole app and webView.
Whenever there is a update in app e.g.: typing events or new message etc we send html content to WebView via this postMessage bridge. And similarly we get scroll, touch/click events from WebView (Message List) to react native app via the same bridge postMessage.
One thing we need to make sure is, bridge should be successfully established before we start communication between two components. Else we will be sending messages from one side while the other side is not yet ready to receive/process messages. Thus this will cause in consistency and the updates will not be observed in the real time.
On current master, we are sending isReady message whenever webView is ready to receive/send/process messages. But the the problem is, what if when webView send isReady message at that time RN part is not ready or this event is not received by RN? We are just ignoring this case currently.
Then according to this RN will always thinks that webView is not ready and will never send any new message to webView, and keep on waiting till it hears isReady from webView.
On current master, one way hand shake is implemented (explained in above paragraph).
Which starts causing problems on Android 9. Issue like:
- Message list only works the second time #3078
- Typing indicator are never shown in the message list.
- More messages are never loaded on scrolling to top/bottom.
- White screen (or message loading) on narrowing to a narrow in which we don't have any message.
Because on such narrow, we request new messages from server and send to webView viapostMessage. So after fetching we want to send new html content to WebView, but RN thinks
WebView is not ready, so it doesn't send. (https://chat.zulip.org/#narrow/stream/48-mobile/subject/messages.20don't.20load/near/655786)
oh, it's a mix. Sometimes loading bars, sometimes not
(https://chat.zulip.org/#narrow/stream/48-mobile/subject/messages.20don't.20load/near/655849)
- etc etc (actually whole communication seems to be broken)
Solution: Improve/enhance this hand shaking mechanism. Implement a two way hand shake.
Keep sending a message from one side till a confirmation from other side is heard/received.
I will prefer to keep this one side as RN one, because we have more control on RN one and it is easier to debug in RN.
(Sending PR in few minutes)
@zulipbot claim