react-native-sse icon indicating copy to clipboard operation
react-native-sse copied to clipboard

Android locks up / does not get receive all initial data (release version)

Open RayHughes opened this issue 2 years ago • 4 comments

Hello!

My team is having issues with Android locking up when compiled with the release flag (production ready). In most cases, the app freezes and prevents user interaction after receiving the initial data. In other cases only a few list items are rendered (5 out of 30).

We are not having any issues on iOS, this library seems to work exceptionally well on that platform.

We are using this in conjunction with Wundergraph client to interact with our graph infrastructure.

https://github.com/wundergraph/wundergraph/blob/7c56ea68215f3a2d93952b891d80b4de699b901a/packages/sdk/src/client/client.ts#L463

RayHughes avatar Nov 30 '23 07:11 RayHughes

Hi. Sorry but I don't think anyone will be able to help you like this. Please provide more information about what exactly you are doing, including:

  • Does the error only happen in release mode or also in debug mode? That is not clear from your description.

  • Have you tried setting the option debug: true for the SSE connection? Do you get any useful logs?

  • only a few list items are rendered (5 out of 30)

    What does that mean? Are you expecting to receive the list item data via SSE? What does the data look like?

EmilJunker avatar Nov 30 '23 17:11 EmilJunker

Does the error only happen in release mode or also in debug mode? That is not clear from your description.

Yes, its happening when compiled for a production build. We have flipper disabled and using the release flag.

We are actually just started experiencing this issue with iOS after more testing, but believe the operating system is doing a better job of masking the issue. We were using previously another polyfill to handle this but had to switch librarihes as the other is unmaintained and had an underlying issue that caused a crash when coming from background. We did not have this issue there.

Have you tried setting the option debug: true for the SSE connection? Do you get any useful logs?

We will take a look and report back.

What does that mean? Are you expecting to receive the list item data via SSE? What does the data look like?

Yes, we receive a list of a couple hundred items that are only relevant for about 20 seconds at a time. It's sports betting data so the data updates very fast and we need to provide it to our clients in near realtime.

The list is updated via json patch

--

The best way for me to describe it is that the library seems to be hanging on the event and buffering the output. I created an endpoint that delivers SSE of just a timestamp and it seems to be hanging delivering a record or two in some cases.

I think the issue is with XmlHttpRequest as it's not really ideal for network streaming as it caches the whole stream buffer until the connection is closed. In cases with fast updating data like ours this can be catastrophic.

RayHughes avatar Nov 30 '23 18:11 RayHughes

More info on XMLHttpRequest Streaming:

https://hpbn.co/xmlhttprequest/#streaming-data-with-xhr

https://github.com/react-native-community/discussions-and-proposals/issues/99#issue-404506330

RayHughes avatar Nov 30 '23 19:11 RayHughes

More info on XMLHttpRequest Streaming:

https://hpbn.co/xmlhttprequest/#streaming-data-with-xhr

https://github.com/react-native-community/discussions-and-proposals/issues/99#issue-404506330

You can use react-native-oksse library for android and this library for ios. For me it works perfect.

Splicer97 avatar Mar 05 '24 17:03 Splicer97