Building Firefox and Firefox source code
So starting on bug 677122. This is my first real Firefox bug.
I figure I need to find the code that initiates the parser for the URI and also find the code that should refresh the URI, and re initiate the parser. I notice doing something similar with a URL anchor, changing it, then hitting enter updates the page. So I should also find this code, and see how that happens.
The very first thing I did was went to view some source code. I went to Mozilla cross reference. This is an online search and reference of the Firefox source code. I searched for “media fragment” and found nsMediaFragmentURIParser.cpp, and from there, found nsHTMLMediaElement.cpp. Some really exciting code in the HTMLMediaElement code is ProcessMediaFragmentURI. This block of code calls the parser, and sets the video’s time based on the values returned from the parser. So now, I need to find the places that should also be doing this.
I think though, this is as far as I can go with simply reading source code like a novel. I have some code that looks interesting, and is a good place to start. It is time to start breaking the code. By that, I mean remove, change, or add some code in areas that look interesting, then compile the code, run it, and see if my changed code runs when I suspect it will run. To do this, I need to get the source, and be able to compile it.
I have done this before, I even have blog posts on doing this… but it was ages ago, but things have changed, and I need an update anyway, so I think I will start freshfrom the online build instructions. I am doing this on a Windows 7, so that may add an extra level of complexity.
I need Visual Studio of sorts. I have Visual Studio 2010. I also need to download the Mozilla build tools for Windows. Once downloaded and installed, I run start-msvc10.bat, with the 10 being for that I use VS 2010. If I had VS 2008 I would of ran start-msvc8.bat, etc. All commands are run inside this shell.
Next I download the source code by running “hg clone http://hg.mozilla.org/mozilla-central”. My first attempt I got “abort: stream ended unexpectedly (got 98688 bytes, expected 125068)”. Second time, no errors, took forever.
Next is to build it. I do this by changing into the new directory mozilla-central, which was created when I did the last command. Then, I run “make -f client.mk” and wait. On my Windows laptop this took 30+ minutes, but it seemed to finish without a hitch. I may consider going through tips for making builds faster, but for now, I will confirm that it worked. After the build is done, to confirm that it worked, I ran “obj-i686-pc-mingw32/dist/bin/firefox.exe”.
That concludes my adventures in building Firefox and exploring the source code. Next time, I will get into hacking and debugging. Then maybe making a diff and submitting a patch!