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

ByteArrayDeviceConnection overflow #150

Open
kenjdavidson opened this issue Nov 25, 2021 · 0 comments
Open

ByteArrayDeviceConnection overflow #150

kenjdavidson opened this issue Nov 25, 2021 · 0 comments
Labels
android bug Something isn't working

Comments

@kenjdavidson
Copy link
Owner

kenjdavidson commented Nov 25, 2021

ByteArrayDeviceConnection:

  • overflow issues
  • concurrency issues

Re: @wallaroo implement thread safe fifo ring buffer

Ya, that could definitely be an issue, although I'm not sure what the use case would be for multiple threads/requests attempting to read. For the most part the top two choices now are:

listener (which won't have this issue)
interval (which again should only be firing once at a time)
I'm not sure the case where multiple concurrent reads will happen, at least in how my company uses this. I think the more appropriate way from a React Native standpoint is to have listener or interval updating the scope/context and having multiple > screens/processes read from the scope/context.
I'm more worried about a Buffer Overflow exception when there is no listener at this point.

i'm worried about receiving data (buffer write) in the DeviceConnection Thread during a read in the React thread...
a threadsafe fifo ring buffer should be safer...

Right now the BufferSize is READ_SIZE (1024) which is also the individual read request size. So it's possible that after a single read the buffer could be full if there is no listener.

Although I'm unsure what the standard should be?

BufferSize = READ_SIZE * X???
even with this, if no listener the buffer could overflow
The only other option is before adding to the buffer check how much there is
Fill from current to end
reset to start
rewrite the remaining over the start
I don't have nearly enough experience with managing buffers and streaming data to know if that's an acceptable choice.

i'm thinking about a serial comm .... the rx buffer is a circular fifo buffer: the producer writes the head, the consumer reads the tail... if the producer completes the the free space it silently overwrite unread tail data...

@kenjdavidson kenjdavidson added bug Something isn't working android labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant