Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactNative Android takes main thread when stream is used >5 times/second #1223

Closed
1 task done
newah opened this issue Jul 19, 2018 · 3 comments
Closed
1 task done

Comments

@newah
Copy link

newah commented Jul 19, 2018

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

Have a stream that fires many times/second.

  • report a bug

Current behaviour

Works fine with iOS.
On Android it gives warning "Setting a timer for a long period of time, i.e. multiple minutes" - in reality from what I've read, setTimeout isn't handled well in RN Android and I think creating/clearing so many timeouts simply floods the thread.

The problem seems to be resetting clreaing/setting timeout for heartbeat every time we receive an event.

Steps to reproduce (if the current behaviour is a bug)

If we flood this example with events, the app responds extremely slowly while receiving stream of events https://github.com/vinnyoodles/react-native-socket-io-example .

I'm not sure I can share our stream link publicly with which the lagging is visible in provided example. But if this problem appears severe enough, we can try to share it privately.

Expected behaviour

Receiving stream of events without lagging the whole thread.

Setup

  • OS: Android (RN 0.55.4, React 16.4.0)
  • socket.io version: 2.1.1

Other information (e.g. stacktraces, related issues, suggestions how to fix)

I've seen comments about using AlarmManager on Android for correct timeouts handling.

Has anyone else experienced such a problem? Is there a better solution?

Probably using socket.io natively would solve such problems, but there's no supported RN wrapper.

@darrachequesne
Copy link
Member

Did you try with various values of pingInterval / pingTimeout ? Any effect?

It seems to be a recurring problem with React Native:

Not sure how we could improve that..

@newah
Copy link
Author

newah commented Jul 20, 2018

In the end we simply filtered the stream to send events at most every second and this solved the problem.

Release build was working better (naturally)
Smaller ping interval/timeout didn't seem to have obvious effect.

Also tried https://github.com/ocetnik/react-native-background-timer which tries to use AlarmManager rather than RN defined timeouts - didn't seem to have any effect.

Have you tested client performance with a high frequency data stream yourself?

@darrachequesne
Copy link
Member

Closed due to inactivity, please reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants