Categories
Coding Experience Fun Nerdy Talk Technical

Regressions: I make code, then I break code

Greetings! First of all, I would like to apologize for the long break. I was on leave and thus could not find time to be active here! So it’s time to be twice as hardworking to finish everything that lagged behind! (And create quality blogs as well XD)!

So this post is about regressions, what are they, and how do they work? Well…

A software regression is a type of software bug where a feature that has worked before stops working. This may happen after changes are applied to the software’s source code, including the addition of new features and bug fixes.
Again, google to the rescue! But anyway, so you get the general idea! It is about something that used to work (but not now)! So what happens is that in a big project with many moving parts, It is almost impossible to keep track of what new code changes can break other features. Even a seasoned programmer can make mistakes of accidentally breaking some other parts of code while implementing something new. (or perhaps fixing bugs) 
Although checks are in place, which help avoid frequent regressions like Buildbot tests ScummVM uses where each new addition is checked against several test cases already prepared, and their output is compared to expected ones! This is all automated, so much testing is done without much effort (except for setting it up XD).
So it’s been so many weeks already, and as we speak, I am on my last day for mid-evaluation. One question you might ask is:
“Hey HSK, working for so long, didn’t you break things? ie Regressed something?? I see all the good codes and how everything is magically working but where’s the dark part??”
The answer is

Regressions Introduced:

Popup Menu leaks

Linked to #5005 where I first implemented the popup menu, there are some occasional memory leaks(if you have no idea what this is, read the section “Leaks are dangerous” from my previous blog), which I have yet to find concrete ways to reproduce, however with some time I am sure it will be fixed.

Symbol and String Comparison

Related to #5107 where I fixed a comparison between symbol and string and evidently a lot of bugs in total distortion, Well.. I was wrong, Symbol and String are never equal on basic level, just sometimes when used to retrieve items from list using those as keys, do they behave like same! Fixed in #5158 where I moved the code to appropriate location and get everything working.

BDFScaler Scaling

Related to #5125 where I improved the text font scaling algorithm which was initially implemented by another student, however even though I managed to fix many bugs but there were still some more left which were very tricky and we had to disable that feature again in-favour of better GUI.

WinFonts Scaling Memory Leaks

Related to #5126. where I initially implemented Windows font scaling, well some leaks were not being accounted for (ie, scaling fonts), fixed in #5136

Well, even as we speak, and for the sake of open pull requests, We are never sure when another regression is introduced, but what I can do is make sure to fix the regressions and thus help in improving the stability of the director engine! Let’s look at some of the ways to fix/identify regressions:

Git bisect to save us here!

Read more about the git bisect command from here, what it does is to use Binary searching to systematically checkout commits and ask you if the commit is “good” or “bad”, depending upon your answers it will point out where things broke!

It is such a simple and powerful feature that you can traverse thousands of commits in 10 iterations! (for nerds that will be log2(1000) or 9.965 iterations, don’t ask me how)

It is so good that I once wrote a tweet about it:

that is it for the regressions and the dark part.. let’s see what I fixed for these weeks and my work so far!

This week

Use “me” to set “the perFrameHook”

Implemented in #5152, this allows for expressions like

set the perFrameHook to me

total-distortion was using this to assign hooks to call itself perframe using this expression, this is a special case where “me” is used to point current object instance to set “the perFrameHook” property!

Fix the working of m_perform properly

m_perform is a lingo handler to execute an object’s method, much similar to “do(command)”, there were errors when this was used inside mAtFrame, but after proper debugging and discussions it has been fixed by a change in #5153, however the change was little unorthodox so a test is also created in-case it breaks in future.

Fix the execution sequence of lingo scripts in case of frame jumps!

As fixed in #5156 where lingo executions inside the handler were being called immediately after frame jumps, ie (go commands) without waiting for the frame to load. Fixed this by freezing the execution of lingo and waiting before the frame is properly loaded before executing any remaining window!

 

The End

Thank you for reading so far, I would love to hear your thoughts and any feedback/suggestions, as usual apology for any grammatical mistakes and writing errors and especially the long delay for this blog, anyway with that being said, see you next week!

Leave a Reply

Your email address will not be published. Required fields are marked *