MissingBackpressureException even .onBackpressureDrop() is added?
See original GitHub issueHey. I’m using RxAndroidBle for connection / writing data etc stuffs. And with long stream operation like subscribe to resource ( 1-3min) I got MissingBackpressureException ( bottom of source code with Log.e). Any idea what is wrong here?
// Setup notifications for incoming data
RxBleConnection connection = connectionMap.get(bleMac);
Subscription notifySubscription = connection.setupNotification(notifyCharacteristic)
.doOnNext(new Action1<Observable<byte[]>>() {
@Override
public void call(Observable<byte[]> observable) {
Log.d(TAG, "Notifications set, calling bypassConnect()");
// Bypass connect in WB to make it aware of this new device
String wbAddress = addressMap.getOrCreateWbAddress(bleMac);
bleWrapper.bypassConnect(wbAddress);
}
})
.flatMap(new Func1<Observable<byte[]>, Observable<byte[]>>() {
@Override
public Observable<byte[]> call(Observable<byte[]> observable) {
return observable;
}
})
.onBackpressureDrop()
.subscribe(new Action1<byte[]>() {
@Override
public void call(byte[] bytes) {
dataAvailable(bleMac, bytes);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
Log.e(TAG, "dataAvailable() Error: " + throwable);
}
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (6 by maintainers)
Top Results From Across the Web
MissingBackpressureException even .onBackpressureDrop ...
Hey. I'm using RxAndroidBle for connection / writing data etc stuffs. And with long stream operation like subscribe to resource ( 1-3min) I ......
Read more >MissingBackpressureException even .onBackpressureDrop ...
I have problem with MissingBackpressureException. I added few .onBackpressureDrop() just for the test but still getting exception.
Read more >MissingBackpressureException (RxJava Javadoc 1.3.8)
Represents an exception that indicates that a Subscriber or operator attempted to apply reactive pull backpressure to an Observable that does not implement ......
Read more >Dealing with Backpressure with RxJava - Baeldung
Our compute() function is simply printing the argument. ... Observer and thus they may still lead to MissingBackpressureException.
Read more >RxJava — Flowables — What, when and how to use it?
Observables are those entities which we observe for any event. ... be reasonably backpressured and cause unexpected > MissingBackpressureException (i.e., ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Finally I had time to dig into this issue. I have prepared a peripheral that sends out ~400 notifications per second and it worked as long as the consumer was quick:
Then I have made the consumer slower by adding a
Thread.sleep(10)
and I quickly gotMissingBackpressureException
. I have then started to play with.onBackpressureDrop()
and adding it right before.subscribe()
did not fixed the issue. I have checked theJavadoc
of.onBackpressureDrop()
and it says:Then I have checked the
Javadoc
of.subscribe()
:This means that applying
.onBackpressureDrop()
just before.subscribe()
does nothing as the.subscribe()
is not applying backpressure to the upstream..onBackpressure*()
should be applied before an operator that applies backpressure to the upstream i.e..observeOn(Scheduler)
whichJavadoc
says:i.e. this will work:
but this will not:
Summary: the behaviour of the library is correct. The aim of
RxAndroidBle
is to provide all BLE events to the user. Applying backpressure mechanisms inside the library would make it harder for the user to understand why they would not get all the notifications the device has sent if they consume them too slow.@TeemuStenhammar Sorry for such a delay (I was on holiday)—could you add on what phone did the problem surfaced? How quick and of what size the notifications are?