Disconnecting the B4A bridge slows down the app

positrom2

Active Member
Licensed User
Longtime User
Hello,
My B4A app is running 50% faster (!!!) when the B4A bridge (I use wireless) is connected to the PC. This is reproducable, but very nasty. I have thrown out any log statement which might be considered as the reason, but that does not help. Is there any idea for a fix (or reason)?

Thanks, positrom2

Remark: the 50% slowing down is the overall effect. I am doing data transmission to a µcontroller, and it appears that when the bridge is not connected, there are random (?) delays in the app execution that cause the handshaking sequence to fail with the consequence of messing up the transmission sequence, causing that delay.
 
Last edited:

positrom2

Active Member
Licensed User
Longtime User
I am quite sure (on slowing down when disconnected), relation to the GC messages?

Erel,
This effect is there with 95% or more security (the slowing down just by disconnecting the bridge on the PC). When I have the WiFi bridge connected the app runs smoothly. I am doing no change on the µC side.

As I said, data transmission via BT gets disturbed under these circumstances, and extra transmission loops have to be inserted, what is the apparent reason for the slowing down. I can get the data transmission back to normal for a minute, but the slowing down effect comes in again, and again, when the bridge is not connected.

Notably: Without logging data the Logcat window shows information when the bridge is connected. Disconnected, couldn't that have influence backwards to the app, some handshaking or so?

Most nastly, when I am demonstrating the artwork away from home (without having the B4A PC nearby) the slowdown is present, supporting my conclusion on the influence of the bridge connection to the app performance.

Regards, positrom2

Addendum, relation to GC:
When the bridge is connected Logcat shows (unfiltered) garbage collection actions occuring every minute or so, when my app is running. Now, GC in itself is not the issue since when the bridge is connected my app runs smoothly. So, might it be that the log messages are filling a buffer in the tablet which is not cleared when the bridge is disconnected, and cleared by timeout?
 
Last edited:
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
Erel, thanks,
The logs are handled by the OS and are not cleared when B4A-Bridge accesses them.
But what happens when B4A bridge does not access them?

Definitely, the app is "stuttering" and "non-stuttering" in relation to disconnecting and connecting the Wifi-Bridge. I have checked that many times. Since GC presumably goes on independently on bridge connection the problem must arise when bridge communication is disabled.
Regards, positrom2
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
The relation between the connection state of the B4A bridge (connected vs. disconnected, WiFi) and the performance of my app is totally evident.

The app is running at its extremes. I am trying to do "real-time" data transfers via BT, as fast as possible. There might be "quirks" in my code, giving the operation system not much time to breath. However, meanwhile it works nicely provided the B4A bridge is connected as discussed in my previous posts. I wonder if somebody could give a hint to a potential reason (and cure, if possible).
Regards, positrom2
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
Benchmark written in B4A?

Thanks, Erel for that hint. It would be helpful if the slow-down effect when B4A-bridge is not connected could be demonstrated by a stand-alone application.

Is there any benchmark available written in B4A, like "0xbench"?
https://code.google.com/p/0xbench/
Thanks, positrom2
 
Upvote 0

Jondroid

Member
Licensed User
Longtime User
bridge without bluetooth available?

Well, I tried to do some trouble shooting on the described problem. Especially, I was interested to see if it is possible to reduce the problem to something which is independent of all the other things (bluetooth and external electronics...)
But first I had a look into the source code of the bridge and it seems to me that the bluetooth and wifi are not strictly seperated. E.g. in the service module it says:
B4X:
WifiServer.Close
BluetoothServer.Disconnect
or in the Activity_Create I read:
B4X:
BAdmin.Initialize("BAdmin")
independent if I want to use a Bluetooth connection or not.

This may or may not be related to the problem but I was just surprised.

Erel, do you have an earlier version of the bridge available that I can check if without the bluetooth part the observations of the OP are reproducible?
 
Upvote 0

Jondroid

Member
Licensed User
Longtime User
Ping latency goes up if the bridge is disconnected

Also, I made some other investigations, which can be tried by anyone out there so we may get a better understanding how the problem described by the OP can be solved.

Again, I'm not sure if this is entirely related but then the effect seems to be the same:

If the bridge is connected on the android phone and I ping from my computer that IP I get a latency of a few milliseconds. Sometimes 3ms or 5ms but it is generally very fast.

However, as soon as I disconnect the bridge the ping time fluctuates dramatically and is on average on a much higher level. Many times it's in the 100ms region but I've even seen indiviual packages which were at more than 500ms.

So, to me it would be very interesting to understand how this happens as it would be very beneficial to keep the latency to a minimum.

Any ideas would be greatly appreciated.
 
Upvote 0
Top