RxBonjour
RxBonjour copied to clipboard
Terrible message: Skipped 119 frames! The application may be doing too much work on its main thread.
Hi there is a very fat issue in you lib.
First i am registrate service :
private var disposableBonjourBradcast: Disposable = Disposables.empty()
val chatNameCode = PrefProvider.getInstance().currentTourCode
val broadcastConfig = BonjourBroadcastConfig(
type = "_$chatNameCode._tcp",
name = PrefProvider.getInstance().userId,
address = inetAddress,
port = tcpServerPort,
txtRecords = mapOf(
HOST to inetAddress.hostAddress!!,
TCP_PORT to tcpServerPort.toString(),
UDP_PORT to udpServerPort.toString(),
USER_ID to PrefProvider.getInstance().userId,
USER_TYPE to PrefProvider.getInstance().myCurrentRole,
USER_NAME to PrefProvider.getInstance().userName,
))
disposableBonjourBradcast = rxBonjour.newBroadcast(broadcastConfig)
.onErrorComplete { throw ConnectionException(it) }
.subscribeOn(Schedulers.io())
.subscribe()
It is work ok.
But when i try to unsubscribe for re -register service for example to pull to-refresh by this :
disposableBonjourBradcast.dispose()
My screen became freeze some during milliseconds. In logcat i see terrible message:
I/Choreographer: Skipped 119 frames! The application may be doing too much work on its main thread.
Thanks for reporting. I'm assuming you're using version 2.0.0-RC1
of the library? What Driver
do you use? Could you use the performance monitors to pin-point what methods might cause this lag?
I know that tearing down a JmDNS
instance on disposal is quite costly, but that work is already supposed to be deferred to an I/O thread.
Use "de.mannodermaus.rxjava2:rxbonjour:2.0.0-RC1" version Use JmDNS
private val rxBonjour: RxBonjour = RxBonjour.Builder() .driver(JmDNSDriver.create()) .platform(AndroidPlatform.create(MyApplication.getInstance())) .create()
As for performans i can show screen:
I hope this may help you
Thank you for the information! Looks like indeed the library's deferring of the JmDNS instance teardown isn't working as expected in your case. JmDNS#close()
taking a long time to complete isn't necessarily an issue with RxBonjour, but rather related to how it's written in JmDNS (related issue: https://github.com/jmdns/jmdns/issues/82). I'll review why the computation thread assigned to that work blocks the main thread.
To be assured of this, can you place a breakpoint into JmDNSBroadcastEngine
on line 37 (the body of the Completable
used to close the JmDNS instance, inside the teardown()
method)? I'll try to reproduce the issue as well.