-
Notifications
You must be signed in to change notification settings - Fork 582
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
RxBleRadio operation off main thread #136
Comments
@dariuszseweryn Copying your answer from a different thread (see here):
|
I agree with that statement and I don't want to put to much burden on you guys about maintaining this list, mainly also because it means that we get aware of such problems when people report them. From our current tests on multiple different devices (nexus 4, nexus 5, LG g5, motorola, a Chinese phone, Samsung s3 mini, HTC tablet, another tablet I don't recall the model), we never had any issue running off the main thread yet. Note that we never tested on API 18 however, our lowest target was a Samsung S3 mini running API level 19. An in-between could be to keep main thread only for API level 18 (or even more restricted). But I understand it might difficult for you guys to maintain. As a first thing, you would guys allow a way for us, users of the library, to change the default scheduler? Not sure how it would look like, but if you agree, I would be happy to check some ways about doing this. |
Hello, |
@dariuszseweryn When I first implemented the flashing, I did it in a debug screen that is doing little to no UI at all. Then, when I ported the code to the actual real UI screen, the performance was dramatically being impacted by I would say a 1.5x to 2x factor (going from 70s to around 130s depending on the run and device). It was to such extend that we suggested to beta testers to actually close the phone screen when flashing to improve speed (no UI was giving the BLE operations almost full control of main thread). But, indeed, a custom operation could resolve both of my issue. First, I would be able to schedule the operation off the main thread (doing it at my own risk) and also access lower level components for speed improvements. I will try to come up with some numbers once I integrated the changes we did last week into the project. At this point, I will test the impact of running the operation on & off the main thread (and only this change) and come up with some numbers for you. Like I say, the impact it not really important when we do minor operations (read & write a few characteristics). It was more painful when transferring lots of data and UI displaying some intensive graphics (progress, chart, etc.) |
This may become relevant to an app I'm developing to support a BLE peripheral data acquisition device. It sends blocks of data (up to 4KB) as fast as possible. The data needs to be graphed on the Android screen as it arrives, so there may be little or no benefit to receiving it on a different thread. I had been thinking to receive on an io thread, perhaps analyze and format the data on a compute thread, and hand off to the UI thread just to draw the graph. Any advice or comments appreciated—and apologies in advance if I am misunderstanding the issue. |
@RobLewis You say that the data needs to be displayed on the screen as it arrives - so I assume that the central (phone) is receiving the data via notification mechanism - in this situation there is no real benefit of this issue as it only touches operations that are performed from the central side (explicit characteristic read, characteristic write, setup notifications, etc.). Getting the notifications is a totally different story as it is executed on a different thread all along. @maoueh Have you been able to check if this issue is still valid for you by any chance? |
@dariuszseweryn On my side, since the addition of custom operations, I can do it on my own if needed. So for me, it's not relevant anymore. |
Summary
I would like to have a way to schedule bluetooth operation off the main thread.
Ultimately, it would be nice if the library was doing this on it's own so that everybody can benefit from it without further interventions. But I understand this might mean keeping a list of devices that needs to execute on the main thread.
We have such fix in the wild right now (not in mass production but tested on lots of various devices), and never heard about problems with it. In our code, if phone is
samsung
and at API level 18, we do stuff on main thread, on all other cases, it's being done on a dedicated single thread schedulerThe text was updated successfully, but these errors were encountered: