Android Tutorial Rapid Debugger

Basic4android v3.0 includes a new debugger named rapid debugger.

SS-2013-10-01_09.57.39.png


The rapid debugger is a very sophisticated debugger with features not available in any other native Android development tool.

The rapid debugger is an important addition to Basic4android. It will increase your productivity as it makes the "write code -> test result" cycle much quicker.

Using this deployment mode is similar to using the standard debugger ("legacy" debugger).


Rapid Debugger advantages

  • Very quick compilation and installation. Usually in less than one or two seconds.
  • In most cases (after the first installation) there is no need to reinstall the APK. This means that the deployment is much quicker. With B4A-Bridge there is no need to approve the installation.
  • Hot code swapping (edit and continue). You can modify the code while the app runs, hit Save and the code will be updated.
  • Powerful variables browser:

    SS-2013-10-01_10.16.01.png
  • Watch Expressions (v3.50):

    SS-2014-02-23_14.48.37.png

    Allows you to evaluate expressions during breakpoints.
Limitations

  • The runtime execution in this mode is slower. In some cases it is slightly slower and in others it can be significantly slower. The rapid debugger is not suitable for debugging "real-time" games or CPU intensive tasks. This is why the legacy debugger is kept.
    Starting from v3.50 the runtime performance of the rapid debugger is close to Release mode.

  • Hot code swapping is very powerful. You can even add subs or modify existing subs. However you cannot add or remove global variables.
  • Unlike the legacy debugger, the app cannot run when the IDE is not connected. It will wait for 10 seconds for the IDE to connect and then exit.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Under the hood (simplified view)

So how does the rapid debugger work?

I will start with an explanation about the legacy debugger. When you compile in Debug (legacy) the B4A compiler creates a regular Android APK. However in addition to the program code the compiler generates instrumented code. This means that for each line it adds a runtime check to test whether there is a breakpoint on that line. If there is a breakpoint the program pauses by showing a modal dialog and the variables data is sent to the IDE over the connection.

The rapid debugger works differently. When you compile your code it creates two applications. A device application (shell) and a standard Java application (debugger engine).

Your code resides in the debugger engine. The debugger engine runs on the desktop. The shell application is like a mini-virtual machine. The debugger engine connects to the shell app and sends the instructions to the shell app. The interesting part of this is that your code is not executed on the device. It is executed on the desktop.
In most cases the shell app can be reused. If for example you add a new file or edit the manifest file with the manifest editor then the compiler will create a new shell app and will reinstall it automatically during compilation.

The standard JVM is more powerful than Android Dalvik machine. It allows for example to load classes at runtime. This is how code swapping is supported.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Sounds awesome Erel! Having the ability to make code changes during debug execution will be fantastic & something I have really been missing since I started using B4A. I'm going to download v3.00 & try it today!

UPDATE: Having used it already today - it's great! I did run into one issue because I was trying to test some network comms on 2 devices. I had to run one device on the "legacy" debug code & the other on the "rapid" debug because of the need for rapid debug to connect to the IDE. Apart from that, it works great & is very fast after the initial compile & install.
 
Last edited:

joneden

Active Member
Licensed User
Longtime User
Ah this was one of the major issues that I had with debugging. Great news - well done. Installing beta now!
 

JohnC

Expert
Licensed User
Longtime User
Very cool - will check it out in a few days.
 

dreamworld

Active Member
Licensed User
Longtime User
This is a great achievement!

But if you can enable B4A to debug multi threads, B4A is a full development tool.
 

stevel05

Expert
Licensed User
Longtime User
Erel,

I always knew you were a genius, this is the last bit of proof!

Steve
 

klaus

Expert
Licensed User
Longtime User
I am pleased to give my feeling after having worked some hours on a big project with the Rapid Debugger in 'real conditions' fine tuning the drawing of a sketch. I could do it only since beta version 8.
It is a real pleasure working with it and a HUGE efficiency improvement in developpment time.
Many many thank's Erel !

Best regards.
 
Last edited by a moderator:

gpe

Member
Licensed User
Longtime User
I couldn't believe it!
Just received the e-mail, I cannot wait to try it hoping to spare hours of work.
As a matter of fact, my "method" of programming is "try and hope it works ! "
Thanks Erel
 

Bas Hamstra

Member
Licensed User
Longtime User
I did a quick test with GenyMotion and the rapid debugger seems to work fine! And fast too! GM and RD are two GREAT additions! Since the old debugger did not work with HAXM image I had to start another ultraslow emulator for debugging. Not anymore!

If you like to develop on your desktop, get Genymotion now! It boots in seconds and runs faster than your phone and seems to integrate fine with B4A.

Thanks Erel and Jim

Bas
 

Eduard

Active Member
Licensed User
Longtime User
Erel, thanks very much for the code swapping feature. Very useful, especially on large projects.:)

Did you try the rapid debugger with GenyMotion?
I just installed GenyMotion too and tested it. It works really good and I can recommend it to everybody because of it's speed. It's probably a thousand times faster than rapid debug using a bluetooth or wifi bridge. Using wifi bridge in combination with rapid debugger is not working here at all. Way too slow because of latency. GenyMotion is great, it makes rapid debug rapid.

Unfortunate the version of SQLCipher used in the b4a library will not work with GenyMotion because this uses a x86 cpu. Hope this will be updated, see my post: http://www.b4x.com/android/forum/threads/sqlcipher-error-on-bluestacks-x86.27244/#content
 

tchart

Well-Known Member
Licensed User
Longtime User
The rapid debugger is not suitable for debugging "real-time" games or CPU intensive tasks. This is why the legacy debugger is kept

Good to know, I just tried my time keeping app and it was counting very slowly.

Also I build my UI through code. I noticed that the text size etc doesn't update when I hit Ctrl+S. I suspect the UI is not refreshed? If I stop debugging and start it again its very quick and the UI changes are there.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Also I build my UI through code. I noticed that the text size etc doesn't update when I hit Ctrl+S. I suspect the UI is not refreshed? If I stop debugging and start it again its very quick and the UI changes are there.
Not exactly. The code is updated. However if Activity_Create already ran then the changes will not be applied. The changed code is not applied "retroactively".

You can use the restart app (red arrow) to start the app from the beginning.
 
Top