Wednesday, August 19, 2009
After going to production, we encountered a serious bug where a web page simply stucked and made the browser freeze. This page is a little bit complex: It contains three views with interaction between them, so we had much trouble with this page in the past. We weren't suprised to hear that this page causes us more trouble, so we went on to debugging.
One of the views in this page get two parameters from the web page (using Panorama's SDK) - fromDate and toDate, which define a time interval for the view to slice on. After debugging, we've found that the problem was that after updating the fromDate parameter and before updating the toDate parameter, the view had no rows left. When trying to update the toDate parameters in the view with no rows, it made the browser stuck.

The solution is to make the parameters update in one action. There are two ways of doing this:
The first one is to use the CallUpdateParametersEx with number of parameters. You can update many parameters in one function call (look in the SDK documentation). The problem with this solution is that the code is not readable.
The second and better solution is to use the EnterBatchCommandMode and LeaveBatchCommandMode functions to make the parameters update in one transaction. This way, the code is much more readable. You can update every parameter in its own CallUpdateParametersEx call. The usage of this function is very simple: Call the EnterBatchCommandMode function before the parameters update and call the LeaveBatchCommandMode after that.

I'm sure that there are more scenarios where this concept can be helpful, so it's important to get familiar with.

 |