<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Bluish Coder: mozilla</title>
 <link href="http://bluishcoder.co.nz/tag/mozilla/atom.xml" rel="self"/>
 <link href="http://bluishcoder.co.nz/"/>
 <updated>2011-12-16T21:17:53+13:00</updated>
 <id>http://bluishcoder.co.nz/</id>
 <author>
   <name>Chris Double</name>
   <email>chris.double@double.co.nz</email>
 </author>

 
 <entry>
   <title>Performing Compatible Updates of Mozilla Central Git Forks</title>
   <link href="http://bluishcoder.co.nz/2011/10/28/performing-compatible-updates-of-mozilla-central-git-forks.html"/>
   <updated>2011-10-28T16:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/10/28/performing-compatible-updates-of-mozilla-central-git-forks</id>
   <content type="html">&lt;p&gt;Earlier this year I posted about &lt;a href='/2011/02/10/git-conversion-of-mozilla-central.html'&gt;how I created my git mirror&lt;/a&gt; of the mozilla-central mercurial repository. I&amp;#8217;ve been keeping a &lt;a href='https://github.com/doublec/mozilla-central'&gt;fork on github&lt;/a&gt; updated regularly since then that a number of people have started using.&lt;/p&gt;

&lt;p&gt;Users of my mirror have wanted to be able to keep up to date with the mercurial mozilla-central repository themselves, or add updates from other branches of the Mozilla source. It takes a large amount of time to start a conversion from scratch but it&amp;#8217;s possible to start from the existing git mirror, perform the incremental updates from mercurial yourself, and still stay compatible with the incremental updates I push to my github mirror.&lt;/p&gt;

&lt;p&gt;&lt;a href='http://hg-git.github.com/'&gt;hg-git&lt;/a&gt; uses a &lt;code&gt;git-mapfile&lt;/code&gt; in the &lt;code&gt;.hg&lt;/code&gt; directory of the mercurial clone to keep track of the mapping between mercurial and git commits. By using the same &lt;code&gt;git-mapfile&lt;/code&gt; that I use for my mirror you can start your own incremental update from the latest data in the &lt;code&gt;git-mapfile&lt;/code&gt; instead of from the beginning. I keep an up-to-date &lt;code&gt;git-mapfile&lt;/code&gt; in &lt;a href='http://www.bluishcoder.co.nz/git-mapfile.bz2'&gt;git-mapfile.bz2&lt;/a&gt;. It&amp;#8217;s compressed with &lt;code&gt;bzip2&lt;/code&gt; as the uncompressed version is quite large.&lt;/p&gt;

&lt;p&gt;The steps to start your own update process are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the &lt;a href='https://hg.mozilla.org/mozilla-central'&gt;mercurial mozilla-central repository&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;Clone my &lt;a href='https://github.com/doublec/mozilla-central'&gt;git mirror&lt;/a&gt; as a bare repository in &lt;code&gt;.hg/git&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Place the &lt;code&gt;git-mapfile&lt;/code&gt; in &lt;code&gt;.hg&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Do an &lt;code&gt;hg bookmark -f -r default master&lt;/code&gt; to mark the commit to convert to&lt;/li&gt;

&lt;li&gt;Perform &lt;code&gt;hg gexport&lt;/code&gt; to update &lt;code&gt;.hg/git&lt;/code&gt; with recent mercurial commits&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;code&gt;.hg/git&lt;/code&gt; directory should now be up-to-date with respect to the mercurial repository. And the additional git commits will have the same SHA id as any commits I push into my mirror when I perform my own update.&lt;/p&gt;

&lt;p&gt;The steps to do an incremental update are the normal:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pull from the mercurial mozilla-central repository&lt;/li&gt;

&lt;li&gt;Run &lt;code&gt;hg bookmark -f -r default master&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Run &lt;code&gt;hg gexport&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;Push or pull to/from &lt;code&gt;.hg/git&lt;/code&gt; as needed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As a working example, the following shell commands on a Linux system should set up your own repository ready for incremental updating:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ hg clone https://hg.mozilla.org/mozilla-central
$ cd mozilla-central/.hg
$ git clone --bare git://github.com/doublec/mozilla-central.git git
$ wget http://www.bluishcoder.co.nz/git-mapfile.bz2
$ bunzip2 git-mapfile.bz2
$ cd ..
$ hg bookmark -f -r default master
$ hg gexport
$ cd .hg/git
$ git push --all ~/some/other/repo.git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Incremental updates just repeat the last few commands above:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ hg pull -u
$ hg bookmark -f -r default master
$ hg gexport
$ cd .hg/git
$ git push --all ~/some/other/repo.git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that I use &lt;code&gt;hg gexport&lt;/code&gt; and push from the &lt;code&gt;.hg/git&lt;/code&gt; repository using the &lt;code&gt;git&lt;/code&gt; command instead of doing an &lt;code&gt;hg push&lt;/code&gt; and relying on &lt;code&gt;hg-git&lt;/code&gt; to do the conversion and push. In my &lt;a href='http://www.bluishcoder.co.nz/2011/02/10/git-conversion-of-mozilla-central.html'&gt;original article&lt;/a&gt; I did the latter. The &lt;code&gt;hg-git push&lt;/code&gt; method uses slower python based routines to do the push which can take a long time and large amounts of memory on big repositories like mozilla-central. By splitting this up into &lt;code&gt;gexport&lt;/code&gt; and using the native &lt;code&gt;git&lt;/code&gt; command I save a lot of time and memory.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Temporal Media Fragment Support in Firefox</title>
   <link href="http://bluishcoder.co.nz/2011/08/08/temporal-media-fragment-support-in-firefox.html"/>
   <updated>2011-08-08T12:00:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2011/08/08/temporal-media-fragment-support-in-firefox</id>
   <content type="html">&lt;p&gt;The W3C has a &lt;a href='http://www.w3.org/2008/WebVideo/Fragments/'&gt;Media Fragments Working Group&lt;/a&gt; whose &lt;a href='http://www.w3.org/2008/01/media-fragments-wg.html'&gt;mission&lt;/a&gt; is to specify temporal and media fragments in the Web using URI&amp;#8217;s. The &lt;a href='http://www.w3.org/TR/media-frags'&gt;draft specification&lt;/a&gt; goes through in detail how these fragments work. I recently became a member of the working group and I&amp;#8217;ve been working on adding support for the &lt;a href='http://www.w3.org/TR/media-frags/#naming-time'&gt;temporal dimension portion&lt;/a&gt; of the specification to Firefox.&lt;/p&gt;

&lt;p&gt;In the most basic form you can specify a start time and an end time in the fragment part of a URI in an HTML video or audio element. For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;video src=&amp;#39;/mediafrag/AudioAPI.webm#t=50,100&amp;#39;&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &amp;#8216;#t&amp;#8217; portion of the URI identifies the fragment as being a temporal media fragment. In this example &amp;#8216;50,100&amp;#8217; means start the video at a current time of 50 seconds, and stop playing at 100 seconds. There are various other formats for the temporal media fragment &lt;a href='http://www.w3.org/TR/media-frags/#naming-time'&gt;defined in the specification&lt;/a&gt;. Examples can be seen in the &lt;a href='http://www.w3.org/2008/WebVideo/Fragments/TC/ua-test-cases.html'&gt;UA Test Cases&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Development of this feature is being done in &lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=648595'&gt;bug 648595&lt;/a&gt;. I&amp;#8217;ve done test builds of the first iteration of the patch and they are available at my &lt;a href='http://www.bluishcoder.co.nz/mediafrag/'&gt;Firefox media fragment test builds page&lt;/a&gt;. The page has builds, an example, and a list of limitations which are currently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temporal syntax only. This means no spatial or track dimensions.&lt;/li&gt;

&lt;li&gt;NPT time support only. No SMPTE time codes or Wall-clock time codes.&lt;/li&gt;

&lt;li&gt;When changing the media fragment portion of a URL the media is not immediately updated. You need to refresh the page to see the change. This is most noticeable when directly navigating to the video and adding or changing a fragment.&lt;/li&gt;

&lt;li&gt;The user interface for identifying the fragment in the standard controls is ugly and needs polish.&lt;/li&gt;

&lt;li&gt;The HTML standard includes an &amp;#8216;initialTime&amp;#8217; attribute for obtaining the start time. There is no way to obtain an end time so I&amp;#8217;ve exposed a &amp;#8216;mozFragmentEnd&amp;#8217; attribute on the video DOM object.&lt;/li&gt;
&lt;/ul&gt;</content>
 </entry>
 
 <entry>
   <title>WDCNZ HTML Media Presentation</title>
   <link href="http://bluishcoder.co.nz/2011/08/08/wdcnz-html-media-presentation.html"/>
   <updated>2011-08-08T09:30:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2011/08/08/wdcnz-html-media-presentation</id>
   <content type="html">&lt;p&gt;Last month I went down to Wellington to give a joint talk at the &lt;a href='http://wdcnz.com/'&gt;WDCNZ&lt;/a&gt; conference. The topic was &amp;#8220;HTML Media: Where we are and where we need to go&amp;#8221;. The talk was shared between &lt;a href='http://blogs.msdn.com/b/nigel'&gt;Nigel Parker&lt;/a&gt;, Mobile and Developer Evangelist for Microsoft, and myself. The conference was excellent with some great speakers and talks.&lt;/p&gt;

&lt;p&gt;Nigel and I covered using HTML video and audio elements and how they can be used today across multiple browsers and mobile devices. We also covered upcoming API&amp;#8217;s and directions in the web media area. Demo&amp;#8217;s were shown on Microsoft Internet Explorer 9, Windows Phone 7 (running the Mango update which has a browser that supports HTML media) and Firefox. Nigel has slides and a summary &lt;a href='http://blogs.msdn.com/b/nigel/archive/2011/07/18/wdcnz-html-media-where-we-are-amp-where-we-need-to-go.aspx'&gt;in his blog post about the talk&lt;/a&gt;. I think it took a bit for attendees to get over the shock over a Mozilla and Microsoft representative sharing the stage and working together! Nigel&amp;#8217;s post explains how this came about.&lt;/p&gt;

&lt;p&gt;I spoke to a few Kiwi developers afterwards about using HTML video and there was a fair bit of interest in using it. The main obstacles seemed to be people unsure what codec to use and wanting support for adaptive streaming. The first is an education issue, getting people aware of what codecs to support for maximum coverage across browsers and how to encode to those formats. With regards to adaptive streaming there has been discussion between interested parties in various mailing lists and groups - it&amp;#8217;s definitely something that is wanted.&lt;/p&gt;

&lt;p&gt;At the time of the talk Nigel and I weren&amp;#8217;t able to find any existing New Zealand based sites that use HTML video. Hopefully this will change in the future and Microsoft New Zealand are leading by example by &lt;a href='http://www.microsoft.com/nz/rwc2011/'&gt;using HTML video&lt;/a&gt; on their own site.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>My Git Workflow for Mozilla Development</title>
   <link href="http://bluishcoder.co.nz/2011/04/16/my-git-workflow-for-mozilla-development.html"/>
   <updated>2011-04-16T17:00:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2011/04/16/my-git-workflow-for-mozilla-development</id>
   <content type="html">&lt;p&gt;Since my post on &lt;a href='/2011/02/10/git-conversion-of-mozilla-central.html'&gt;converting mozilla-central to git&lt;/a&gt; I&amp;#8217;ve had a few requests about what my git workflow is for Mozilla Development.&lt;/p&gt;

&lt;p&gt;When working on bugs I&amp;#8217;ll create a git branch for development. The workflow in this branch looks like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fetch origin
git checkout -b bug/123456 origin/master
...make changes...
git commit
...make more changes...
git commit&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Occasionally I&amp;#8217;ll want to merge with the latest code from mozilla-central. I do this by rebasing my changes on top of the latest trunk code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fetch origin
git rebase origin/master&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&amp;#8217;ll often have multiple temporary branches as I work on different ideas during the fix. I find being able to diff between the branches, cherry pick patches, etc useful.&lt;/p&gt;

&lt;p&gt;When I&amp;#8217;ve finished with the fix and want to generate a patch for review I rebase on top of trunk and squash all my commits down into one patch. I do this use git&amp;#8217;s interactive rebase:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fetch origin
git rebase -i origin/master
...squash commits into one commit and set commit message to my checkin commit message...
git hgp &amp;gt;~/mypatch.patch&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The last command, &lt;code&gt;git hgp&lt;/code&gt;, uses an alias I got from &lt;a href='http://blog.mozilla.com/respindola/2011/04/14/producing-patchs-for-hg-with-git/'&gt;Rafael Espindola&amp;#8217;s Blog&lt;/a&gt;. You can install this alias by adding the following to your &lt;code&gt;~/.gitconfig&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[alias]
hgp = show --format=\&amp;quot;From: %an &amp;lt;%ae&amp;gt;%n%s%n%b\&amp;quot; -U8&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The adds an &amp;#8216;hgp&amp;#8217; git command that does the same as &lt;code&gt;git show&lt;/code&gt; but includes a header for the committers name. This allows an &lt;code&gt;hg import&lt;/code&gt; of the patch to include the correct patch authors details which is useful if you use the &lt;code&gt;checkin-needed&lt;/code&gt; keyword for others to commit the patch.&lt;/p&gt;

&lt;p&gt;I attach the patch file to the bug for review. If I get review comments I then go back to the git branch and make the necessary changes. Regenerating the patch involves repeating the steps above.&lt;/p&gt;

&lt;p&gt;When the patch needs to be committed to mozilla-central it can be imported and pushed directly using mercurial:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central
hg import ~/mypatch.patch
hg push&lt;/code&gt;&lt;/pre&gt;</content>
 </entry>
 
 <entry>
   <title>A Quick Look at the Rust Programming Language</title>
   <link href="http://bluishcoder.co.nz/2011/03/31/a-quick-look-at-the-rust-programming-language.html"/>
   <updated>2011-03-31T20:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/03/31/a-quick-look-at-the-rust-programming-language</id>
   <content type="html">&lt;p&gt;The &lt;a href='https://github.com/graydon/rust'&gt;Rust Programming Language&lt;/a&gt; is a systems programming language being developed by Mozilla. It was announced last year and has seen quite a bit of development since then.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve only been lightly following the development over the past year but recently decided to spend a bit more time looking at it. The following is a look at the language and implementation from someone who isn&amp;#8217;t heavily involved in the development so don&amp;#8217;t take anything I write as gospel. Hopefully I don&amp;#8217;t get too many things wrong.&lt;/p&gt;

&lt;p&gt;The &lt;a href='https://github.com/graydon/rust/wiki/Language-FAQ'&gt;Rust Language FAQ&lt;/a&gt; lists the following summary of features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory safe. No null pointers, wild pointers, etc. Automatic storage management.&lt;/li&gt;

&lt;li&gt;Mutability control. Immutable by default. No shared mutable state across tasks.&lt;/li&gt;

&lt;li&gt;Dynamic execution safety: task failure / unwinding, trapping, logging. RAII / dtors.&lt;/li&gt;

&lt;li&gt;Typestate system: ability to define complex invariants that hold over data structures.&lt;/li&gt;

&lt;li&gt;Explicit memory control. Layout and allocation control. Interior / value types.&lt;/li&gt;

&lt;li&gt;Very lightweight tasks (coroutines). Cheap to spawn thousands-to-millions.&lt;/li&gt;

&lt;li&gt;Stack iterators (effectively lambda-blocks w/o heap allocation).&lt;/li&gt;

&lt;li&gt;Static, native compilation. Emits ELF / PE / Mach-o files.&lt;/li&gt;

&lt;li&gt;Direct and simple interface to C code (switch stacks and call, ~8 insns).&lt;/li&gt;

&lt;li&gt;Multi-paradigm. pure-functional, concurrent-actor, imperative-procedural, OO.&lt;/li&gt;

&lt;li&gt;First class functions with bindings.&lt;/li&gt;

&lt;li&gt;Structurally-typed objects (no nominal types or type hierarchy).&lt;/li&gt;

&lt;li&gt;Multi-platform. Developed on Windows, Linux, OSX.&lt;/li&gt;

&lt;li&gt;UTF8 strings, assortment of machine-level types.&lt;/li&gt;

&lt;li&gt;Works with existing native toolchains. GDB / Valgrind / Shark / etc.&lt;/li&gt;

&lt;li&gt;Practical rule-breaking: can break safety rules, if explicit about where and how.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Rust implementation is still in the &amp;#8216;only useful for Rust developers&amp;#8217; state since the implementation and libraries are still being developed. There are two Rust compilers in various states of development. They are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rustboot - written in O&amp;#8217;Caml with it&amp;#8217;s own x86 code generation backend. This is being used to bootstrap the &amp;#8216;rustc&amp;#8217; implementation.&lt;/li&gt;

&lt;li&gt;rustc - self hosting compiler written in Rust and bootstrapped using &amp;#8216;rustbost&amp;#8217;. Code generation is done using LLVM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;rustboot&lt;/code&gt; can be used to write Rust programs and try out the language. &lt;code&gt;rustc&lt;/code&gt; is still in heavy development and only very basic stuff works from what I can see.&lt;/p&gt;

&lt;h2 id='building'&gt;Building&lt;/h2&gt;

&lt;p&gt;Please note, as of 2011-10-24, the instructions for building Rust below are out of date. For updated instructions read &lt;a href='/2011/10/24/building-rust.html'&gt;my recent post on building Rust&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;a href='https://github.com/graydon/rust/wiki/Getting-started'&gt;instructions to build Rust&lt;/a&gt; are in the wiki. One important point is you need an SVN version of LLVM. I built this from source using a git mirror of LLVM (on 64 bit x86 Linux):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone git://github.com/earl/llvm-mirror.git
$ cd llvm-miror
~/llvm-mirror $ CXX=&amp;#39;g++ -m32&amp;#39; CC=&amp;#39;gcc -m32&amp;#39; CFLAGS=-m32 CXXFLAGS=-m32 \
                LDFLAGS=-m32 ./configure --enable-shared --disable-bindings \
                 --{build,host,target}=i686-unknown-linux-gnu \
                 --enable-targets=x86,x86_64,cbe
~/llvm-mirror $ make &amp;amp;&amp;amp; make install&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once you have LLVM and the other pre-requisites installed:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone git://github.com/graydon/rust.git
$ cd rust
~/rust $ mkdir build
~/rust $ cd build
~/rust/build $ ../configure
~/rust/build $ make check&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This builds the &lt;code&gt;rustboot&lt;/code&gt; compiler, uses that to compile &lt;code&gt;rustc&lt;/code&gt;, then runs a series of tests using both builds. If you have &lt;code&gt;valgrind&lt;/code&gt; installed this will be slow as the tests are run under &lt;code&gt;valgrind&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id='bootstrap_compiler'&gt;Bootstrap Compiler&lt;/h2&gt;

&lt;p&gt;The bootstrap compiler executable is &lt;code&gt;boot/rustboot&lt;/code&gt;. The command to execute it, assuming the build occurred in the directory &lt;code&gt;~/rust/build&lt;/code&gt; is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o hello hello.rs&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will compile a Rust program in &lt;code&gt;hello.rs&lt;/code&gt; and leave an executable &lt;code&gt;hello&lt;/code&gt;. The &lt;code&gt;-L&lt;/code&gt; argument references the &lt;code&gt;boot&lt;/code&gt; subdirectory containing the Rust standard library in &lt;code&gt;libstd.so&lt;/code&gt;. A &amp;#8216;hello world&amp;#8217; program for testing is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;

fn main() {
  log &amp;quot;Hello World&amp;quot;;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To run the executable you&amp;#8217;ll need to adjust the &lt;code&gt;LD_LIBRARY_PATH&lt;/code&gt; to include the &lt;code&gt;rt&lt;/code&gt; subdirectory to pick up the Rust runtime shared library:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o test test.rs
~/rust/build $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/rust/build/rt
~/rust/build $ ./hello
rt: ---
rt: ca09:main:main: rust: Hello World&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='rustc_compiler'&gt;rustc Compiler&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;rustc&lt;/code&gt; compiler lives in &lt;code&gt;stage0/rustc&lt;/code&gt;. The output of this compiler is LLVM bytecode which must then be compiled using LLVM tools. To compile the &lt;code&gt;hello.rs&lt;/code&gt; program mentioned in the previous section:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/rust/build/rt:~/rust/build/rustllvm
~/rust/build $ stage0/rustc -nowarn -L stage0 -o hello.bc hello.rs
~/rust/build $ llc -march=x86 -relocation-model=pic -o hello.s hello.bc
~/rust/build $ gcc -fPIC -march=i686 -m32 -fno-rtti -fno-exceptions -g \
               -o hello.o -c hello.s
~/rust/build $ gcc -fPIC -march=i686 -m32 -fno-rtti -fno-exceptions -g \
               stage0/glue.o -o hello hello.o -Lstage0 -Lrt -lrustrt&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note the need to add the &lt;code&gt;rustllvm&lt;/code&gt; directory to &lt;code&gt;LD_LIBRARY_PATH&lt;/code&gt; to pick up a shared library. That sequence of commands will compile the &lt;code&gt;hello.rs&lt;/code&gt; file to LLVM bytecode. &lt;code&gt;llc&lt;/code&gt; compiles the bytecode to x86 assembly. &lt;code&gt;gcc&lt;/code&gt; compiles this to an object file, followed by a final &lt;code&gt;gcc&lt;/code&gt; invocation to link it. And to run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ ./hello
rt: ---
rt: ee0b:main:main: rust: Hello World&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='rust_language_details'&gt;Rust Language Details&lt;/h2&gt;

&lt;p&gt;For examples of the Rust language there are multiple tests and the source code to &lt;code&gt;rustc&lt;/code&gt; itself in the &lt;a href='git://github.com/graydon/rust.git'&gt;github repository&lt;/a&gt;. The &lt;a href='https://github.com/graydon/rust/wiki'&gt;wiki&lt;/a&gt; has a link to the PDF documentation, &lt;a href='https://github.com/downloads/graydon/rust/rust-2011-02-25-snap.pdf'&gt;currently a snapshot from 2011-02-25&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The following are some quick examples of Rust features that work with the bootstrap compiler.&lt;/p&gt;

&lt;h3 id='foreign_function_interface'&gt;Foreign Function Interface&lt;/h3&gt;

&lt;p&gt;This program uses the C FFI to call the &amp;#8216;puts&amp;#8217; function from the C shared library:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._str.rustrt.sbuf;
import std._str;

native mod libc = &amp;quot;libc.so.6&amp;quot; {
    fn puts(sbuf s) -&amp;gt; int;
}

unsafe fn main() {
  libc.puts(_str.buf(&amp;quot;hello from C\n&amp;quot;));
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Compile and run with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o cffi cffi.rs
~/rust/build $ ./cffi
hello from C&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='command_line_arguments'&gt;Command Line Arguments&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

fn main(vec[str] args) {
  for(str s in args) {
    log s;
  }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; function takes a vector of strings as the argument. This holds the command line arguments passed to the program. The example iterates over the vector printing out each element.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o args args.rs
~/rust/build $ ./args a b c
rt: ---
rt: ccca:main:main: rust: ./args
rt: ccca:main:main: rust: a
rt: ccca:main:main: rust: b
rt: ccca:main:main: rust: c&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='factorial'&gt;Factorial&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

fn fac(uint x) -&amp;gt; uint {
  if (x &amp;lt;= 1u) {
    ret 1u;
  }
  else {
    ret x * fac(x-1u);
  }
}

fn main() {
  log fac(5u);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;No language is complete without showing how factorial can be computed.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ ./fac
rt: ---
rt: d158:main:main: rust: 120 (0x78)&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='spawning_tasks'&gt;Spawning Tasks&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

impure fn logger(port[str] logs) {
  let int i = 0;
  while (i &amp;lt; 2) {
    auto msg &amp;lt;- logs;
    log msg;
    i = i + 1;
  }
  log &amp;quot;logger exited&amp;quot;;
}

impure fn main() {
  let port[str] logs = port();
  let task p = spawn logger(logs);
  auto out = chan(logs);
  out &amp;lt;| &amp;quot;Hello&amp;quot;;
  out &amp;lt;| &amp;quot;World&amp;quot;;
  join p;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A port is the receiving end of a typed inter task communication mechanism. A channel is the sending end of the communication mechanism. &lt;code&gt;&amp;lt;|&lt;/code&gt; sends to the port and &lt;code&gt;&amp;lt;-&lt;/code&gt; receives from the channel.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o spawn spawn.rs
~/rust/build $ ./spawn
rt: ---
rt: 9a73:main:spawn.rs:1: rust: Hello
rt: 9a73:main:spawn.rs:1: rust: World
rt: 9a73:main:spawn.rs:1: rust: logger exited&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='types'&gt;Types&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;use std;

tag list {
  nil;
  cons(int, @list);
}

fn list_len(@list l) -&amp;gt; uint {
   fn len(@list l, &amp;amp;uint n) -&amp;gt; uint {
    alt (*l) {
      case (nil) {
        ret n;
      }
      case (cons(_, ?xs)) {
        ret len(xs, n+1u);
      }
    }
  }
  ret len(l, 0u);
}

fn main() {
  let @list l = @cons(1, @cons(2, @cons(3, @nil)));
  log list_len(l);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This example creates a &lt;code&gt;list&lt;/code&gt; type. It has constructors for an empty list, &lt;code&gt;nil&lt;/code&gt;, and a &lt;code&gt;cons&lt;/code&gt; containing an integer and the rest of the list. The &amp;#8217;@&amp;#8217; prefixed to the &lt;code&gt;list&lt;/code&gt; type in places means that that variable holds a boxed object. That is, it&amp;#8217;s a reference-counted heap allocation.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;list_len&lt;/code&gt; function shows the use of a local function which pattern matches over the list (using the &lt;code&gt;alt&lt;/code&gt; keyword) and keeps a running total of the list length. The &lt;code&gt;main&lt;/code&gt; function creates a &lt;code&gt;list&lt;/code&gt; and prints the length.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o types types.rs
~/rust/build $ ./types
rt: ---
rt: 8126:main:main: rust: 3 (0x3)&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id='typestate'&gt;Typestate&lt;/h3&gt;

&lt;p&gt;The typestate system is one of the things that most interests me about Rust. If you&amp;#8217;ve been reading my &lt;a href='http://www.bluishcoder.co.nz/tags/ats/'&gt;ATS&lt;/a&gt; posts, in particular the ones involving &lt;a href='http://www.bluishcoder.co.nz/2011/02/26/reading-data-from-a-file-in-ats.html'&gt;type safe checking of array bounds&lt;/a&gt;, you&amp;#8217;ll know I&amp;#8217;m interested in languages that can help with detecting programming problems at compile time. It seems to me that the typesafe system can help here.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s a contrived example demonstrating one use of typestate. &lt;code&gt;main&lt;/code&gt; takes a vector of strings containing the command line arguments. I want to call a function, &lt;code&gt;dosomething&lt;/code&gt;, that will use these arguments but for some reason there must be never more than 2 arguments. Imagine I&amp;#8217;m calling some C routine that&amp;#8217;ll die if I do.&lt;/p&gt;

&lt;p&gt;I could check at runtime that the number of arguments is less than three. Here&amp;#8217;s an example that does this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._vec;

fn dosomething(&amp;amp;vec[str] args) {
  log &amp;quot;vector length is less than 3&amp;quot;;
}

fn main(vec[str] args) {
  log _vec.len[str](args);
  check (_vec.len[str](args) &amp;lt; 3u);
  dosomething(args);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Some example runs:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o ts1 ts1.rs
~/rust/build $ ./ts1 a
rt: ---
rt: b3b1:main:main: rust: 2 (0x2)
rt: b3b1:main:main: rust: vector length is less than 3
~/rust/build $ ./ts1 a b
rt: ---
rt: d884:main:main: rust: 3 (0x3)
rt: d884:main:main: upcall fail &amp;#39;.t0 &amp;lt; 3u&amp;#39;, ts2.rs:5&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notice the last invocation has failed since three arguments are used (the program name is counted as an argument).&lt;/p&gt;

&lt;p&gt;It would be good to be able to check at compile time that somewhere the assertion holds that the number of arguments is less than three. In our example if we left the &lt;code&gt;check&lt;/code&gt; call out, the program would still compile, but &lt;code&gt;dosomething&lt;/code&gt; might do something disasterous. We can tell the typestate system that the precondition must hold for callers of &lt;code&gt;dosomething&lt;/code&gt; and to fail at compile time by adding a &amp;#8216;prove statement&amp;#8217; to the function:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._vec;

fn prove_length(&amp;amp;vec[str] args, uint n) -&amp;gt; bool {
  ret _vec.len[str](args) &amp;lt; n;
}

fn dosomething(&amp;amp;vec[str] args) : prove_length(args, 3u) {
  log &amp;quot;vector length is less than 3&amp;quot;;
}

fn main(vec[str] args) {
  log _vec.len[str](args);
  dosomething(args);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The addition of &lt;code&gt;: prove_length(args, 3u)&lt;/code&gt; to the function tells the typestate system that this boolean function must evaluate to true. It examines what it knows of the constraints made via &lt;code&gt;check&lt;/code&gt; statements and the like to see if it can prove that this is the case. If it is not then a compile error occurs. The above program will fail to compile:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o ts2 ts2.rs
ts2.rs:14:13:14:19: error: Unsatisfied precondition constraint prove_length(args, 3u) &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If we add a &lt;code&gt;check&lt;/code&gt; statement we are adding an assertion check that this precondition holds. Typestate makes note of this and will now allow that call to &lt;code&gt;dosomething&lt;/code&gt; to compile:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use std;
import std._vec;

fn prove_length(&amp;amp;vec[str] args, uint n) -&amp;gt; bool {
  ret _vec.len[str](args) &amp;lt; n;
}

fn dosomething(&amp;amp;vec[str] args) : prove_length(args, 3u) {
  log &amp;quot;vector length is less than 3&amp;quot;;
}

fn main(vec[str] args) {
  log _vec.len[str](args);
  check prove_length(arg, 3u);
  dosomething(args);
}

~/rust/build $ OCAMLRUNPARAM=&amp;quot;b1&amp;quot; boot/rustboot -L boot -o ts3 ts3.rs
~/rust/build $ ./ts3
rt: ---
rt: d9e6:main:main:                       rust: 1 (0x1)
rt: d9e6:main:main:                       rust: vector length is less than 3&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It&amp;#8217;ll be interesting to see how typestate is used in the standard library and third party libraries to help with compile time checking of code.&lt;/p&gt;

&lt;h2 id='conclusion'&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Rust is an interesting language and there&amp;#8217;s quite a bit more to it than I&amp;#8217;ve covered here. I just picked random features to try. I&amp;#8217;m looking forward to &lt;code&gt;rustc&lt;/code&gt; being more complete and trying out some of the language features in more &amp;#8216;real world&amp;#8217; examples to get a feel for it.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>New Wave Audio Backend Landed</title>
   <link href="http://bluishcoder.co.nz/2011/03/31/new-wave-audio-backend-landed.html"/>
   <updated>2011-03-31T16:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/03/31/new-wave-audio-backend-landed</id>
   <content type="html">&lt;p&gt;Yesterday I landed &lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=635649'&gt;bug 635649&lt;/a&gt; on &lt;a href='https://hg.mozilla.org/mozilla-central'&gt;mozilla-central&lt;/a&gt;. This is a refactoring of the wave backend for the HTML audio element. The initial work on this bug was done by &lt;a href='http://blog.mjg.im/'&gt;Matthew Gregan&lt;/a&gt; with me completing the patch.&lt;/p&gt;

&lt;p&gt;Prior to this landing the wave backend implemented the HTML audio API itself, sharing very little implementation details with the other audio backends. This meant the backend had to implement the intricate details of what events get raised and when they get raised. When we wrote the WebM backend we refactored the code so we could share this sort of thing amongst backends. This bug refactored the wave backend to share this code.&lt;/p&gt;

&lt;p&gt;The advantages of this are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Less likelihood of &amp;#8216;wave backend only&amp;#8217; bugs.&lt;/li&gt;

&lt;li&gt;Less code to maintain.&lt;/li&gt;

&lt;li&gt;The &lt;a href='https://wiki.mozilla.org/Audio_Data_API'&gt;Audio Data API&lt;/a&gt; can now use wave files as this was implemented in the shared backend code.&lt;/li&gt;
&lt;/ul&gt;</content>
 </entry>
 
 <entry>
   <title>Git Conversion of Mozilla Central</title>
   <link href="http://bluishcoder.co.nz/2011/02/10/git-conversion-of-mozilla-central.html"/>
   <updated>2011-02-10T14:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/02/10/git-conversion-of-mozilla-central</id>
   <content type="html">&lt;p&gt;The Mozilla repository for Firefox development, &lt;a href='http://hg.mozilla.org/mozilla-central'&gt;mozilla-central&lt;/a&gt;, is a mercurial repository. I prefer using &lt;a href='http://git-scm.com/'&gt;git&lt;/a&gt; for version control so I usually do my Firefox development using a &lt;a href='http://www.bluishcoder.co.nz/2008/12/changes-to-git-mirror-of-firefox.html'&gt;git mirror&lt;/a&gt; of the mozilla-central repository.&lt;/p&gt;

&lt;p&gt;To convert the repository into git I used &lt;a href='http://repo.or.cz/w/fast-export.git'&gt;hg-fast-export&lt;/a&gt;. This has worked well over the last couple of years. Unfortunately I&amp;#8217;ve noticed that my git mirror and the official mercurial repository differ slightly. The git mirror contains files that have been deleted or moved in the official repository and lately the mirror has stopped building due to some commits not being correctly converted. As a result I stopped updating my mirror and used mercurial directly.&lt;/p&gt;

&lt;p&gt;I still prefer developing using git though so I tried the &lt;a href='http://hg-git.github.com/'&gt;hg-git mercurial plugin&lt;/a&gt;. This took about six days on my laptop to do the conversion and peaked at 14GB of memory. The result was a git repository with a working tree that, according to diff, is an exact copy of the original mercurial repositories working tree. Another nice feature of the hg-git is that commit id&amp;#8217;s in the resulting git repository are the same across multiple runs of hg-git. This would allow other users to push and pull from a git repository that they converted independently.&lt;/p&gt;

&lt;p&gt;To perform the conversion I installed hg-git and ran the following series of commands:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mkdir git
$ cd git
$ git init --bare
$ cd ..
$ hg clone https://hg.mozilla.org/mozilla-central hg
$ cd hg
$ hg bookmark -r default master
$ hg push ../git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Six days and 14GB later, the resulting git repository ended up being about 7GB in size. I did a &lt;code&gt;git gc --aggressive&lt;/code&gt; on it to get this down to 200MB. Incremental updates of new mercurial commits are done with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cd hg
$ hg pull -u
$ hg bookmark -f -r default master
$ hg push ../git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&amp;#8217;ve pushed a mirror of this to github at &lt;a href='http://github.com/doublec/mozilla-central'&gt;http://github.com/doublec/mozilla-central&lt;/a&gt;. I&amp;#8217;m using this for development and will see if it is able to continue importing without diverging from the original mozilla-central source.&lt;/p&gt;

&lt;p&gt;More information about the use of git for Mozilla development can be found in the followup posts I did on the subject:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href='/2011/04/16/my-git-workflow-for-mozilla-development.html'&gt;My Git Workflow for Mozilla Development&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href='/2011/10/28/performing-compatible-updates-of-mozilla-central-git-forks.html'&gt;Performing Compatible Updates of Mozilla Central Git Forks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
 </entry>
 
 <entry>
   <title>WebM Decoder in Flash using Alchemy</title>
   <link href="http://bluishcoder.co.nz/2011/01/15/webm-decoder-in-flash-using-alchemy.html"/>
   <updated>2011-01-15T02:10:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2011/01/15/webm-decoder-in-flash-using-alchemy</id>
   <content type="html">&lt;p&gt;&lt;a href='http://unitzeroone.com/blog/'&gt;Ralph Hauwert&lt;/a&gt; has been posting on twitter about work he&amp;#8217;s done on getting WebM decoding to work in Flash by compiling the &lt;a href='http://www.webmproject.org/code/'&gt;libvpx&lt;/a&gt; source code using Adobe&amp;#8217;s &lt;a href='http://labs.adobe.com/technologies/alchemy/'&gt;Alchemy&lt;/a&gt; technology.&lt;/p&gt;

&lt;p&gt;Alchemy is a research project that allows compilation of C and C++ libraries into code that runs on the ActionScript virtual machine used by Flash. Ralph &lt;a href='http://twitter.com/#!/UnitZeroOne/status/25710899566219264'&gt;originally tweeted&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Had a quickshot porting #WebM codec to Flash 10 using libvpx and alchemy. Surprisingly, got a preliminary version to work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He &lt;a href='http://twitter.com/#!/UnitZeroOne/status/25711897814769664'&gt;followed up with a post&lt;/a&gt; saying the intial performance of a 1920x1080 VP8 video with no audio was decoding to YUV at about 1.5 frames per second. He provides an &lt;a href='http://t.co/XGaiLYh'&gt;image&lt;/a&gt; of a decoded frame.&lt;/p&gt;

&lt;p&gt;This is good stuff and it&amp;#8217;ll be worth following his &lt;a href='http://twitter.com/#!/UnitZeroOne'&gt;twitter feed&lt;/a&gt; if you&amp;#8217;re interested in a pure flash implementation of a WebM decoder.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve been interested in having decoders written in JavaScript, which I wrote about in my &lt;a href='http://www.bluishcoder.co.nz/2009/06/05/reading-ogg-files-with-javascript.html'&gt;reading ogg files with JavaScript&lt;/a&gt; post. Maybe something similar to the Flash/Alchemy approach could be done with &lt;a href='http://code.google.com/p/emscripten/'&gt;emscripten&lt;/a&gt;, an LLVM to JavaScript compiler, to get a WebM decoder in JavaScript.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Firefox video scaling during YCbCr to RGB conversion</title>
   <link href="http://bluishcoder.co.nz/2010/11/24/firefox-video-scaling-during-ycbcr-to-rgb-conversion.html"/>
   <updated>2010-11-24T15:00:00+13:00</updated>
   <id>http://bluishcoder.co.nz/2010/11/24/firefox-video-scaling-during-ycbcr-to-rgb-conversion</id>
   <content type="html">&lt;p&gt;When I changed to using the &lt;a href='/2010/03/12/changes-to-firefox-ycbcr-code.html'&gt;Chromium YCbCr color conversion code&lt;/a&gt; I didn&amp;#8217;t use the code that scales the video during the conversion as there was no infrastructure in place to do this at the time.&lt;/p&gt;

&lt;p&gt;What this meant was we&amp;#8217;d do the YCbCr conversion on the original image size and then later, during rendering, scale this using the browser&amp;#8217;s scaling routines. This was slow in the case of large videos being scaled using the &amp;#8216;width&amp;#8217; and &amp;#8216;height&amp;#8217; attributes on video elements.&lt;/p&gt;

&lt;p&gt;YouTube&amp;#8217;s HTML 5 video user interface often scales down. By default it plays a good quality video scaled down to fit the standard YouTube user interface. In Firefox this results in a performance hit due to the slow scaling.&lt;/p&gt;

&lt;p&gt;&lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=577843'&gt;Bug 577843&lt;/a&gt; was raised to address this issue. The fix was to implement scaling at YCbCr conversion time using the scaling code that already existed in Chromium&amp;#8217;s YCbCr code that we were using. This has now landed and will be in Firefox 4 resulting in better video playback when scaled.&lt;/p&gt;

&lt;p&gt;As part of this work I also updated to the latest Chromium code. This was done in &lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=583138'&gt;bug 583138&lt;/a&gt;. This gives more performant conversion routines and better quality. This has also landed recently and will be in Firefox 4.&lt;/p&gt;

&lt;p&gt;For performance comparisons to see if there were improvements in playback I tested video playback using WebM, Theora and a commonly used open source flash-based video player playing an MP4 video. I compared dropped frame statistics using stats available from the flash player and the &lt;a href='/2010/08/24/experimental-playback-statistics-for-html-video-audio.html'&gt;experimental playback statistics&lt;/a&gt; I wrote about earlier.&lt;/p&gt;

&lt;p&gt;For a 1080p sized video, scaled down, the performance on my laptop improved by about 25% with these patches applied and was at least as good as the flash based player. For the Theora video performance was better - I suspect due to the lower CPU requirements to decode Theora video.&lt;/p&gt;

&lt;p&gt;[update from feedback: Removed comment about YouTube&amp;#8217;s fullscreen not being hardware accelerated. Apparently Firefox trunk now accelerates it. Clarified that by &amp;#8216;flash player&amp;#8217; I meant an open source video player written in Flash, not an open source Flash implementation]&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Changes to Firefox Video Implementation</title>
   <link href="http://bluishcoder.co.nz/2010/09/15/changes-to-firefox-video-implementation.html"/>
   <updated>2010-09-15T06:25:00+12:00</updated>
   <id>http://bluishcoder.co.nz/2010/09/15/changes-to-firefox-video-implementation</id>
   <content type="html">&lt;p&gt;I mentioned in my &lt;a href='http://www.bluishcoder.co.nz/2010/08/24/experimental-playback-statistics-for-html-video-audio.html'&gt;previous post&lt;/a&gt; about the Firefox video implementation that some changes were going to be made to make our implementation more spec compliant. These have now landed and will be in Firefox 4. The relevant bugs are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=571822'&gt;Bug 571822&lt;/a&gt; - Fire timeupdate less frequently than once per frame&lt;/li&gt;

&lt;li&gt;&lt;a href='https://bugzilla.mozilla.org/show_bug.cgi?id=584615'&gt;Bug 584615&lt;/a&gt; - Make media progress events be simple events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prior to these landing we would try to fire a &amp;#8216;timeupdate&amp;#8217; event every time a video frame changed. This allowed JavaScript applications to listen to this event and do things (like display subtitles) at fairly accurate time intervals. Unfortunately other browsers fire this event at different rates, usually with about 200ms between events. This made applications non-portable across browsers if they relied on per-frame events. As a result we&amp;#8217;ve moved to firing &amp;#8216;timeupdate&amp;#8217; no more frequently than 250ms. If you need to process time changes more often than this then it&amp;#8217;s best to use &amp;#8216;setTimeout&amp;#8217; or &amp;#8216;setInterval&amp;#8217; to query &amp;#8216;currentTime&amp;#8217; at the rate you need. This will work across all browsers that support the media API.&lt;/p&gt;

&lt;p&gt;The other change was to remove the &amp;#8216;progress&amp;#8217; information from the &amp;#8216;progress&amp;#8217; events. This was driven by a spec change. The &amp;#8216;progress&amp;#8217; events used to contain additional information about the byte position and total number of bytes for the download. This additional information has been removed from the spec and we were the only browser that implemented that part. To prevent cross browser issues we&amp;#8217;ve removed the information too. The alternative is to use the &amp;#8216;buffered&amp;#8217; attribute on the media element and work with time data. &amp;#8216;buffered&amp;#8217; support was also landed recently which is why we can now remove the non-compliant &amp;#8216;progress&amp;#8217; event data.&lt;/p&gt;</content>
 </entry>
 
 
</feed>

