Skip to content

Some events are not emitted in some Android devices #54

@mateo-gallardo

Description

@mateo-gallardo

Description

On some Android devices some events emitted via the sendEvent method in TcpSocketModule are not received in the JS side.
For some reason it seems to be fixed with a Thread.sleep(100) right before any event is emitted in the TcpReceiverTask. Right now I have it before the instantiating the BufferedInputStream and it doesn't fail, but I don't understand why.

Thread.sleep(100);
BufferedInputStream in = new BufferedInputStream(socket.getInputStream());
while (!isCancelled() && !socket.isClosed()) {

Do you have any idea why this could be happening?
I'm guessing it's giving time for another task in another thread to be ready for these events, but I don't know what it is.

Steps to reproduce

Steps to reproduce the behavior:
It's hard to reproduce because it doesn't happen in every device. I've got a Pixel 3 where it works perfectly and a HUAWEI MediaPad 5 where it fails quite often.

I create a connection, send the data and close it immediately.
The Pixel 3 failed 0 out of 100 events emitted.
The HUAWEI tablet failed 51 out of 100 events emitted.
The HUAWEI tablet with the Thread.sleep(100) failed 0 out of 100 events emitted.

Relevant information

| OS | Android |
| react-native | 0.62.2 |
| react-native-tcp-socket | 3.7.1 |

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions