<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vladimir Vukićević &#187; vladimir</title>
	<atom:link href="http://blog.vlad1.com/author/vladimir/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vlad1.com</link>
	<description>Words</description>
	<lastBuildDate>Mon, 26 Jul 2010 21:05:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>EGL &amp; OpenGL ES Come to Windows</title>
		<link>http://blog.vlad1.com/2010/07/26/egl-opengl-es-come-to-windows/</link>
		<comments>http://blog.vlad1.com/2010/07/26/egl-opengl-es-come-to-windows/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 21:05:48 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Canvas 3D]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[amd]]></category>
		<category><![CDATA[drivers]]></category>
		<category><![CDATA[egl]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=325</guid>
		<description><![CDATA[It&#8217;s SIGGRAPH time, and this means all sorts of interesting announcements in the graphics world. One of these came today from AMD, who announced that they plan on shipping both EGL and OpenGL ES drivers on Windows for their recent GPUs. One of the most challenging things in getting Firefox working with WebGL and hardware [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s SIGGRAPH time, and this means all sorts of interesting announcements in the graphics world.  One of these came today from AMD, who <a href="http://blogs.amd.com/developer/2010/07/26/opengl-es-2-0-coming-to-a-desktop-near-you/">announced that they plan on shipping</a> both <a href="http://www.khronos.org/egl/">EGL</a> and <a href="http://www.khronos.org/opengles/">OpenGL ES</a> drivers on Windows for their recent GPUs.</p>
<p>One of the most challenging things in getting Firefox working with WebGL and hardware graphics acceleration has been dealing with platform-specific pieces to get access to OpenGL.  In many cases similar functionality works differently (often in subtle ways), requiring both lots of testing and lots of very specific codepaths.  EGL replaces all of these with a modern system designed with portability in mind.  Until now, however, EGL has only been adopted in the mobile space.  On the desktop, the older GLX, CGL, and WGL subsystems have held this role; in the case of GLX and WGL in particular, they bring along years of accumulated cruft.  </p>
<p>Having a native EGL driver will allow us to ship one particular hardware acceleration provider that will work and be tested across various desktop and mobile platforms.  Additionally, the same provider can connect to the <a href="http://code.google.com/p/angleproject/">ANGLE project</a>, which implements EGL and OpenGL ES on top of Direct3D 9. Having OpenGL ES will allow us to test and develop truly identical code across desktop and mobile.  As mobile graphics development has become important (not just to Mozilla, but in general!), having the same API implemented on the desktop will make it easier to catch problems and portability issues in an environment that&#8217;s much more conducive to development and debugging.</p>
<p>Native OpenGL ES on the desktop will also mean that we can tie our <a href="http://webgl.org/">WebGL</a> implementation directly to it, instead of going through the desktop OpenGL driver.  Because WebGL follows the OpenGL ES specification, the native ES driver on the desktop will allow us to make a more efficient binding between WebGL and the underlying platform, potentially leading to higher performance.</p>
<p>As with any such change, it will be a while before we can depend on the presence of these APIs on the desktop.  These first steps are important to making that change happen.  I&#8217;m looking forward to seeing other vendors following AMD here, both on Windows and on other platforms.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/07/26/egl-opengl-es-come-to-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WinDbg Image Viewer Extension</title>
		<link>http://blog.vlad1.com/2010/07/18/windbg-image-viewer-extension/</link>
		<comments>http://blog.vlad1.com/2010/07/18/windbg-image-viewer-extension/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 21:55:29 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=323</guid>
		<description><![CDATA[Since I often work on graphics code, one of the things I frequently want to do while debugging is take a chunk of memory and view it as an image.  No standard debugger seems to do this, which is surprising given how useful it is.  I&#8217;ve made do with other tools in the past &#8212; [...]]]></description>
			<content:encoded><![CDATA[<p>Since I often work on graphics code, one of the things I frequently want to do while debugging is take a chunk of memory and view it as an image.  No standard debugger seems to do this, which is surprising given how useful it is.  I&#8217;ve made do with other tools in the past &#8212; there&#8217;s a great debugging image viewer somewhere for win32 (I can&#8217;t find it via google this time around) that lets you attach to a process and manually put in an address, dimensions, etc. to grab the data from the process and view it.  It&#8217;s somewhat buggy though, and hasn&#8217;t been udpated in a while.  There&#8217;s also <a href="http://www.billbaxter.com/projects/imdebug/">the image debugger</a>, which is handy, but requires you to link it into your program.</p>
<p>So, I finally wrote the (very simple) debug extension I wish I&#8217;d had.  You can find the <a href="http://vlad.off.net/hg/imext/">source for imext here</a> (it&#8217;s a hg repo), and a <a href="http://vlad.off.net/hg/imext/raw-file/2c619c722db5/bin/imext.dll">binary DLL built for x86 here</a>.  Rename it to imext.dll and drop it alongside your x86 WinDbg.  Use &#8220;<tt>!imext.help</tt>&#8221; to get some basic instructions.  It&#8217;s pretty rough code and only does exactly what I needed yesterday, but it can become more useful pretty quickly.  There are some weird bugs with WinDbg&#8217;s expression evaluators that make it difficult to use with actual expressions; passing addresses directly works better.  Also remember that WinDbg&#8217;s default expression evaluator is MASM, not C++ &#8212; the main thing is that this means that any bare numbers are interpreted as hex (use <tt>0n123</tt> to get decimal).</p>
<p>I&#8217;ll probably extend this quite a bit over time, including teaching it about Mozilla-specific things like gfxImageSurfaces.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/07/18/windbg-image-viewer-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Go Mad While Trying To Render To a Texture</title>
		<link>http://blog.vlad1.com/2010/07/01/how-to-go-mad-while-trying-to-render-to-a-texture/</link>
		<comments>http://blog.vlad1.com/2010/07/01/how-to-go-mad-while-trying-to-render-to-a-texture/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 08:05:18 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Canvas 3D]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[egl]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[tears]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=309</guid>
		<description><![CDATA[Has that happened to you? No? It&#8217;s just me? Really? Huh. (Somewhat technical OpenGL post follows; you&#8217;ve been warned.) So over the past week, I&#8217;ve been trying to make our OpenGL stuff in Firefox be a little more coherent and easy to use, especially when it comes to doing things like rendering to a texture. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Has that happened to you?  No?  It&#8217;s just me?  Really?  Huh.</p>
<p style="text-align: left;">(Somewhat technical OpenGL post follows; you&#8217;ve been warned.)</p>
<p style="text-align: left;">So over the past week, I&#8217;ve been trying to make our OpenGL stuff in Firefox be a little more coherent and easy to use, especially when it comes to doing things like rendering to a texture.  This is something really for WebGL, and is a key to making WebGL fast&#8230; we want it all to live in video hardware, and we want to render it straight from there, instead of doing the horrible readback that it does currently.</p>
<p style="text-align: left;">Our current implementation uses PBuffers for each WebGL context.  PBuffers are old and crufty, but they mostly work ok.  But, everyone kept telling me, &#8220;PBuffers are old and crufty!  FBOs are the new hotness!  Why do you hate unicorns?&#8221;  Problem is, WebGL really wants its own context &#8212; one of the advantages of FBOs over PBuffers is that they <em>don&#8217;t</em> need a separate context.  That&#8217;s great, if what you need is to render to a texture in your game or visualization app or whatever.  But, WebGL needs a context.</p>
<p style="text-align: left;">Ok, I thought, I can just use OpenGL&#8217;s (technically, WGL, EGL, GLX, and CGL&#8217;s) context sharing feature, have everything live in one shared global namespace, and things will just work.  This has one somewhat scary problem &#8212; if you don&#8217;t clean up any resources, they stick around forever, or at least until all the contexts in the sharing group are gone.  But, I figured we can keep track and clean up.</p>
<p style="text-align: left;">So I did all this work, set up a global context to use as a &#8220;shared&#8221; context.  Everything worked great, creating a FBO is certainly easier than creating a PBuffer and all that.</p>
<p style="text-align: left;">And then I decided to test it on Android.  One of the reasons why I wanted to do this was that on a number of mobile devices, among them Nokia&#8217;s N900 and Nvidia&#8217;s Android port, PBuffers cannot be bound as a texture; they just don&#8217;t support that.  The shared-context FBO approach worked great.  Then I plugged in a Nexus One.  Failure.</p>
<p style="text-align: left;">What gives?  It turns out, a bunch of current Android devices simply <em>don&#8217;t support GL context sharing</em>.  My plan?  Ruined.  The full table of tears actually looks like this:</p>
<table style="background-color: #ccffff; text-align: left; width: 80%;" border="0" cellpadding="5" align="center">
<thead>
<tr>
<td style="text-align: center;"><strong>Target</strong></td>
<td align="center"><strong>PBuffers</strong></td>
<td style="text-align: center;"><strong>Sharing</strong></td>
<td style="text-align: center;"><strong>Other</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td>Desktop &#8211; WGL</td>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">YES</td>
<td></td>
</tr>
<tr>
<td>Desktop &#8211; GLX</td>
<td style="text-align: center;">no</td>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">YES</td>
</tr>
<tr>
<td>Desktop &#8211; CGL</td>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">YES</td>
</tr>
<tr>
<td>Maemo (N900 + others)</td>
<td style="text-align: center;">no</td>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">YES</td>
</tr>
<tr>
<td>Android &#8211; Tegra</td>
<td style="text-align: center;">no</td>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">YES</td>
</tr>
<tr>
<td>Android &#8211; Nexus One</td>
<td style="text-align: center;">YES*</td>
<td style="text-align: center;">no</td>
<td></td>
</tr>
<tr>
<td>Android &#8211; Droid</td>
<td style="text-align: center;">YES*</td>
<td style="text-align: center;">no</td>
<td></td>
</tr>
<tr>
<td>Android &#8211; EVO4G</td>
<td style="text-align: center;">YES*</td>
<td style="text-align: center;">no</td>
<td></td>
</tr>
</tbody>
</table>
<p style="text-align: left;">The &#8220;Other&#8221; category means that the platform has an alternate approach that doesn&#8217;t involve either PBuffers or context sharing. These other approaches are:</p>
<p style="text-align: left;">Desktop &#8211; GLX: X11 Pixmaps can be rendered to and used as textures via texture_from_pixmap</p>
<p style="text-align: left;">Desktop &#8211; CGL: I think there&#8217;s some CoreAnimation thing that can be used here?</p>
<p style="text-align: left;">Maemo: X11 Pixmaps, as on GLX; potentially EGL_KHR_gl_texture_2D_image</p>
<p style="text-align: left;">Android &#8211; Tegra: EGL_KHR_gl_texture_2D_image, which allows a texture to be exported as an EGLImage.  This is ideal, since it gives all the benefit of FBOs without any of the downsides of context sharing.  Unfortunately, this is the only place where it&#8217;s supported, and as best I can tell nothing like this exists on the desktop.</p>
<p style="text-align: left;">The * next to some of the Android entries indicates that while they do support pbuffers, they only support power-of-two dimensions, at least for pbuffers that can be bound as textures.  This is annoying and caused me a bunch of grief until I realized that quirk.</p>
<p style="text-align: left;">So, with that information, the new plan is to attempt to share all window contexts&#8217; resources &#8212; there are advantages here in cleanup operations and being able to do texture uploads and other things on different threads.  For WebGL and other offscreen contexts though, we want to avoid sharing if we can, so the order in which we&#8217;ll try things goes like this:</p>
<ol>
<li>EGL_KHR_texture_2d_image + GL_OES_EGL_image.  Even though it&#8217;s only supported on one target, I still want to make sure that we use this where we can &#8212; it really is exactly what we want.</li>
<li>PBuffers.  Yes, they may be old and busted and difficult to create and all that, but if supported, they still do basically exactly what&#8217;s needed.</li>
<li>X11 Pixmaps + texture_from_pixmap.  Basically like PBuffers, but even more annoying and actually supported on X11.</li>
<li>Dummy window or other drawable and a FBO, plus full sharing with the windowed contexts.  This is only possible if sharing is possible, and is a little risky from a resource management perspective, but it works.</li>
<li>Can&#8217;t share, can&#8217;t texture from any renderable target?  Then we call glReadPixels and take the slow boat through system memory.</li>
</ol>
<p>So, where I was hoping to just write one path &#8212; #4 in the list above &#8212; I now have to write 5.  On the plus side, 1-3 all don&#8217;t have the sharing problem.  On the minus side, it&#8217;s 5 separate code paths instead of just 1.</p>
<p>Hopefully the above information saves someone some pain while trying to do offscreen GL rendering on various platforms, especially mobile ones.  I wish the Android EGL implementations were higher quality; the non-Nvidia ones seem to support an identical set of extensions and report identical version strings, which makes me wonder if they&#8217;re just based on some generic code that Google provides.  If so, it would be nice to see that updated with support for texture_2d_image/EGL_image.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/07/01/how-to-go-mad-while-trying-to-render-to-a-texture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Losing My Memory</title>
		<link>http://blog.vlad1.com/2010/05/10/losing-my-memory/</link>
		<comments>http://blog.vlad1.com/2010/05/10/losing-my-memory/#comments</comments>
		<pubDate>Mon, 10 May 2010 21:47:59 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[jemalloc]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=296</guid>
		<description><![CDATA[With the work going on to bring Firefox to mobile devices, and with desktop users demanding more and more from their web browser, memory usage is a concern.  Even with 4GB on desktop and laptops becoming commonplace, and 8GB, 12GB, 16GB etc. becoming not all that unusual, it&#8217;s unnerving to see a web browser eating [...]]]></description>
			<content:encoded><![CDATA[<p>With the work going on to bring Firefox to mobile devices, and with desktop users demanding more and more from their web browser, memory usage is a concern.  Even with 4GB on desktop and laptops becoming commonplace, and 8GB, 12GB, 16GB etc. becoming not all that unusual, it&#8217;s unnerving to see a web browser eating up a large chunk of that.  I&#8217;ve been spending time figuring out how we can improve our memory usage, which starts with finding out where Firefox uses memory to begin with.</p>
<p>Let&#8217;s get one thing out of the way up front.  Today&#8217;s web browser is in many ways acting like a miniature full operating system.  It runs multiple applications at once (whether in multiple windows or tabs).  It might do a lot of background processing.  It can work with large data sets, for example large images on flickr or large spreadsheets on Google Documents.  But, the final memory usage number that the user sees when they open up the Task Manager or Process Viewer is the aggregate memory usage of the entire system.  So, the goal of improving our memory usage is not to get that number to the lowest possible &#8212; doing that would be an unacceptable tradeoff in performance for users &#8212; but instead to understand where memory is being used, and then use that data to improve in those areas as possible.</p>
<p>One comment that I&#8217;ve heard is that Firefox 3.6 seems to use more memory than Firefox 3.0.  My initial tests show this to not be true; specifically, I looked at the &#8220;Private Bytes&#8221; value in the Windows 7 task manager shortly after startup with about:blank, and also after opening a number of tabs (gmail, google docs, cnn.com, front page of the boston.com big picture blog, engadget, and a few others).  Here are the results of a typical run:</p>
<p><center><br />
<table style="border: 1px solid black;">
<tr>
<th>(in kb)</th>
<th>Firefox 3.0</th>
<th>Firefox 3.6</th>
</tr>
<tr>
<th>Blank Page</th>
<td align="right">20,052</td>
<td align="right">21,740</td>
</tr>
<tr>
<th>Multiple Tabs</th>
<td align="right">115,532</td>
<td align="right">109,128</td>
</tr>
</table>
<p></center></p>
<p>The next question is figuring out where all the memory goes.  I&#8217;ve been adding some instrumentation to Firefox to figure out in more detail where memory is being used.  For a sample run with the multiple tabs shown above, here&#8217;s what some of that reporter data looks like:</p>
<p><center><br />
<table style="border: 1px solid black;">
<tr>
<th>Component</th>
<th>Memory (in kb)</th>
<tr>
<th align="left">Windows &#8211; Private Bytes</th>
<td align="right">111,616</td>
</tr>
<tr>
<th align="left">jemalloc &#8211; Commit Size</th>
<td align="right">91,684</td>
</tr>
<tr>
<th align="left">JavaScript &#8211; GC Chunks</th>
<td align="right">11,534</td>
</tr>
<tr>
<th align="left">JavaScript &#8211; NJ Trace Code</th>
<td align="right">128</td>
</tr>
<tr>
<th align="left">JavaScript &#8211; js_malloc Other</th>
<td align="right">30,142</td>
</tr>
<tr>
<th align="left">Images (uncompressed)</th>
<td align="right">53,811</td>
</tr>
<tr>
<th align="left">Graphics Surfaces (win32)</th>
<td align="right">53,967</td>
</tr>
<tr>
<th align="left">PresShell Arenas</th>
<td align="right">6,373</td>
</tr>
</table>
<p></center></p>
<p>Or, graphically:</p>
<p><center><a href="http://blog.vlad1.com/wp-content/uploads/2010/05/foo.png"><img src="http://blog.vlad1.com/wp-content/uploads/2010/05/foo.png" alt="" title="Memory Usage Sample" width="600" height="216" class="aligncenter size-full wp-image-305" /></a></center></p>
<p>There&#8217;s some overlap in those numbers &#8212; for example, the jemalloc commit size is a subset of the Windows Private Bytes number, and most of the rest is a subset of the jemalloc commit size.  Likewise, the uncompressed images number is a subset of the Win32 graphics surfaces number; that is, ~53MB is in use by win32 surfaces, and almost all of that is due to live images in pages (remember that we&#8217;ve got some image heavy sites in that tab set, including the Big Picture blog which has around 10-11 large images on it&#8230; those should account for about 20-25MB just by themselves).</p>
<p>There are some things that don&#8217;t make sense in the above, which mean that my instrumentation isn&#8217;t quite correct&#8230; for example, adding up the JS numbers, the Images number, and the PresShell arenas number brings us beyond the jemalloc commit size, which shouldn&#8217;t be true.  However, some of the Image data is allocated by GDI, likely bypassing jemalloc, so we have to take that into account.  There&#8217;s also some large other chunks of the browser that have yet to be instrumented, which should provide additional insight.</p>
<p>Two initial observations: one, keeping images compressed in memory and only decompressing them briefly when we need to draw them is a potential huge memory win.  We have the infrastructure and code to do this in place; it was disabled recently while some of the internals changed, and it needs to be reenabled.</p>
<p>Two, the 30MB or so in the &#8220;js_malloc Other&#8221; bucket is also pretty curious.  We need to do some more work to figure out what exactly is in here.  (This contains things like data structures for tracking array contents and &#8212; potentally a big one &#8212; string data.)</p>
<p>I&#8217;ll be blogging more as the instrumentation takes shape, and as it gets landed into trunk nightly builds.  Much of this information will be visible in about:memory, and eventually we&#8217;ll be able to give some per-tab memory information as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/05/10/losing-my-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fennec on Android</title>
		<link>http://blog.vlad1.com/2010/04/27/fennec-on-android-ground-zero/</link>
		<comments>http://blog.vlad1.com/2010/04/27/fennec-on-android-ground-zero/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 00:39:39 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=280</guid>
		<description><![CDATA[Over the last few months, we&#8217;ve made some great progress on bringing Firefox to Android.  Michael Wu, Brad Lassey, Alex Pakhotin and I have been focusing on getting a build ready that&#8217;s usable by a broader set of people, and we&#8217;re now ready to get that build out there.  This build should be considered &#8220;pre-alpha&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.vlad1.com/wp-content/uploads/2010/04/fennec-n1.png"><img class="alignright size-full wp-image-286" title="fennec-n1" src="http://blog.vlad1.com/wp-content/uploads/2010/04/fennec-n1.png" alt="" width="240" height="400" /></a>Over the last few months, we&#8217;ve made some great progress on bringing Firefox to Android.  Michael Wu, Brad Lassey, Alex Pakhotin and I have been focusing on getting a build ready that&#8217;s usable by a broader set of people, and we&#8217;re now ready to get that build out there.  This build should be considered &#8220;pre-alpha&#8221;, so there are some warnings and caveats:</p>
<ul>
<li>We&#8217;ve only really tested this on the Motorola Droid and the Nexus One.</li>
<li>It will likely not eat your phone, but bugs might cause your phone to stop responding, requiring a reboot.</li>
<li>Memory usage of this build isn&#8217;t great &#8212; in many ways it&#8217;s a debug build, and we haven&#8217;t really done a lot of optimization yet.  This could cause some problems with large pages, especially on low memory devices like the Droid.</li>
<li>You&#8217;ll see the app exit and relaunch on first start, as well as on add-on installs; this is a quirk of our install process, and we&#8217;re working to get rid of it.</li>
<li>You can&#8217;t open links from other apps using Fennec; we should have this for the next build.</li>
<li>This build requires Android 2.0 or above, and likely an OpenGL ES 2.0 capable device.</li>
<li>Edit: This build must be installed to internal memory, not to a SD card.</li>
</ul>
<p>There also aren&#8217;t yet any automated nightly developer builds or automated updates to this build; it&#8217;s even more of a pre-nightly build (even earlier than pre-alpha).  But, it&#8217;s usable enough that we wanted to get some feedback on it as we continue to develop.</p>
<h3>Weave Sync</h3>
<p>There is an experimental version of Weave that is compatible with this build: from within Fennec on your phone, open the Mozilla Labs weave page at <a href="https://mozillalabs.com/weave/">https://mozillalabs.com/weave/</a> and click on &#8220;Experimental Version&#8221;.  (It&#8217;s to the right of the big <em>Download Weave now!</em> link &#8212; don&#8217;t click on that one though, it&#8217;s an older version.)  Install the add-on, then you&#8217;ll need to restart Fennec (swipe the screen left and then click on the &#8220;gear&#8221; icon to open the browser tools panel, then click on addons and click the Restart button at the top).  Follow the instructions when Fennec restarts.</p>
<h3>Troubleshooting</h3>
<p>Should you run into problems, such as the app not responding or just giving you a black screen, you can force it to quit by going into the Android Settings, selecting Applications, selecting Manage Applications, then selecting Fennec, and tapping Force Stop.  (A utility called <em>White Killer</em>, available from the Market, can do the same job with fewer clicks.)  Worst case, uninstalling and reinstalling would clear out your profile and any saved data.</p>
<h3>Installation &amp; Feedback</h3>
<p><a href="http://bit.ly/fennec-android"><img class="alignleft size-full wp-image-283" title="Fennec for Android QR" src="http://blog.vlad1.com/wp-content/uploads/2010/04/fennec-android-bitly.png" alt="" width="155" height="155" /></a>So, now that you&#8217;ve read all that, you can <a href="http://bit.ly/fennec-android">download the build here</a> &#8212; the easiest way is to download it using your phone&#8217;s browser, and then click on it in the downloads list to install it.  If you&#8217;re reading this on your desktop, you can scan the QR code here on your phone, or type in the following address in your phone&#8217;s browser: <strong>bit.ly/fennec-android</strong>.  You may need to enable installation of non-Market applications by going to Settings, Applications, and checking &#8220;Unknown Sources&#8221;.</p>
<p>We&#8217;ve created a temporary <a href="http://groups.google.com/group/fennec-android-pre-alpha">Google Group for feedback</a> about this pre-alpha build.  In the future we&#8217;ll have a more permanent way for user feedback and comments, but for now, please use the group to let us know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/04/27/fennec-on-android-ground-zero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Progress: March 31 Edition</title>
		<link>http://blog.vlad1.com/2010/03/31/android-progress-march-31-edition/</link>
		<comments>http://blog.vlad1.com/2010/03/31/android-progress-march-31-edition/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 23:12:23 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[fennec]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[gecko]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=272</guid>
		<description><![CDATA[Wow, it&#8217;s great to see how excited people are about getting Firefox running on their Android phones! We&#8217;ve made a bunch of progress in the past few weeks, and we&#8217;ve really ramped up development in the past few days, including bringing new folks onto the project. We&#8217;ve done a bunch of stuff recently; Michael Wu [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, it&#8217;s great to see how excited people are about getting Firefox running on their Android phones!  We&#8217;ve made a bunch of progress in the past few weeks, and we&#8217;ve really ramped up development in the past few days, including bringing new folks onto the project.</p>
<p>We&#8217;ve done a bunch of stuff recently; Michael Wu has done some great work fixing issues with the soft keyboard support and cleaning up rotation behavior.  He&#8217;s also done some more fun things like hooking up the accelerometer to the <a href="http://dougt.org/wordpress/2009/08/orientation/">MozOrientation event</a>.  We&#8217;ve also experimented with a few different rendering approaches, moving from software rendering using private APIs, to using OpenGL, and then moving back to software, but without private APIs this time.  (Turns out, for what we&#8217;re currently doing, non-GL rendering is crazyfast, though that will change once we get our <a href="http://www.basschouten.com/blog1.php/2010/01/18/layers-cross-platform-acceleration">hardware accelerated rendering</a> system going on Android.)</p>
<p>There are still some bugs to fix before we&#8217;re comfortable letting people download nightly builds &#8212; for example, current and older development builds can lock up your phone, requiring killing the process from a debug terminal or rebooting.  Those are the bugs that we&#8217;re spending all of our time on; we don&#8217;t want to have any kind of builds available until we think that our testers will have an acceptable experience (and locking up your phone isn&#8217;t acceptable!).</p>
<p>Having nightly builds available and getting some feedback is an important step before we can even consider releasing an alpha version.  I&#8217;m also working (right now, in fact, while writing this post &#8212; waiting for a build to finish!) on getting Weave ready to be used with our first nightlies, because having your Firefox history and bookmarks synced onto your phone is pretty fantastic.</p>
<p>Here&#8217;s a quick video I took yesterday of using Fennec on a Nexus One:</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/01upBC7ON04&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en_US&#038;feature=player_detailpage&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/01upBC7ON04&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en_US&#038;feature=player_detailpage&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="385"></embed></object></p>
<p>Last but not least, we&#8217;re getting very close to moving all the  patches and changes we have in flight (some in various repos, some just  sitting on our computers) checked in to mozilla-central, so the Android  work will be on the same platform that&#8217;s been seeing <a href="http://twitter.com/shaver/status/11379789967">some fantastic improvements</a> recently.  Remember that about three months ago we had <i>nothing</i> working or even building on Android; now it&#8217;s getting ready to land on the trunk!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/03/31/android-progress-march-31-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three Fennecs, All in a Row</title>
		<link>http://blog.vlad1.com/2010/03/19/three-fennecs-all-in-a-row/</link>
		<comments>http://blog.vlad1.com/2010/03/19/three-fennecs-all-in-a-row/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 00:11:19 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[fennec]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=268</guid>
		<description><![CDATA[After wrestling with OpenGL on Android for a bit, I was finally able to get Gecko on Android rendering using OpenGL.  This was needed to both simplify the build process, removing the need to have private Android headers and libraries available, and also to remove an expensive CPU RGB-&#62;BGR byte swap.  Michael Wu&#8217;s also done [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://blog.vlad1.com/2010/03/19/things-i-learned-today-android-opengl-edition-2/">wrestling with OpenGL</a> on Android for a bit, I was finally able to get Gecko on Android rendering using OpenGL.  This was needed to both simplify the build process, removing the need to have private Android headers and libraries available, and also to remove an expensive CPU RGB-&gt;BGR byte swap.  Michael Wu&#8217;s also done a pile of work, including the all-important keyboard hookup so that you can, you know, type in some URLs or search terms.  (Handy in a web browser.)  Here&#8217;s a little family portrait of Fennec running on a Nexus One, a Motorola Droid, and a display attached to a NVIDIA Tegra 250 devkit.</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2010/03/three-fennecs.jpg"><img class="aligncenter wp-image-269" title="three-fennecs" src="http://people.mozilla.com/~vladimir/misc/three-fennecs.jpg" alt="" width="626" height="470" /></a></p>
<p>We&#8217;re still working on getting the basic blocks in place to where it&#8217;s &#8220;dogfoodable&#8221;, that is, usable by the developers.  The good news is that while the builds are already pretty fast, we&#8217;re seeing that we have a <em>lot</em> of headroom for performance&#8230; especially for visual things like rendering and panning.  Most of the work we&#8217;ve done so far has just been quick work to unblock getting the basic port running; I&#8217;m looking forward to being able to dig deeper into a bunch of these issues!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/03/19/three-fennecs-all-in-a-row/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Things I Learned Today: Android OpenGL Edition</title>
		<link>http://blog.vlad1.com/2010/03/19/things-i-learned-today-android-opengl-edition-2/</link>
		<comments>http://blog.vlad1.com/2010/03/19/things-i-learned-today-android-opengl-edition-2/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 23:58:04 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[gecko]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[opengl es]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=262</guid>
		<description><![CDATA[One of the issues with the Gecko port to Android is that, early on, I used some internals to tie in to the Android graphics system from native code.  This worked fine, but it complicated the build: you needed to pull in a bunch of headers and some libraries from the actual Android source to [...]]]></description>
			<content:encoded><![CDATA[<p>One of the issues with the Gecko port to Android is that, early on, I used some internals to tie in to the Android graphics system from native code.  This worked fine, but it complicated the build: you needed to pull in a bunch of headers and some libraries from the actual Android source to be able to complete a build.</p>
<p>The solution for this was pretty easy: move to OpenGL for rendering.  However, there are some interesting quirks here.  I&#8217;m targeting Android 2.x only: specifically the Motorola Droid, HTC Nexus One, and a NVIDIA Tegra 250 devkit I have here.  For this initial step, all I need is to just draw a textured quad.  We&#8217;ve got full OpenGL compositing, rendering, fancy video decoding and all that stuff coming later, but for now we&#8217;re just hooking into our software rasterizer, uploading the result as a texture, and drawing a textured quad.  Easy, right?  Here are some random issues I ran into while doing this over the past day or two.</p>
<h3>First Attempt: OpenGL ES 1.1</h3>
<p>Well, there are two wrinkles.  First, Cairo&#8217;s software rasterizer uses a 32-bit ARGB pixel format and layout.  In little-endian per-byte terms, that&#8217;s B G R A.  OpenGL ES supports A R G B.  There is an EXT_bgra extension that adds support for GL_BGRA as another byte format, and this extension is one that&#8217;s potentially available on GL ES.  The second wrinkle is that this quad is display-sized, so the texture is display sized; it&#8217;s not going to be power-of-two dimensions.  While OpenGL ES 2.0 supports non power of two textures in the base (with some limitations, which are not relevant for my use case), ES 1.1 does not, and I figured given that all I was drawing is a textured quad, I may as well use ES 1.1.</p>
<p>Unfortunately, the tree devices I mentioned above support different combinations of these.  The NVIDIA device supports both EXT_bgra and ARB_texture_non_power_of_two.  This is perfect; no workarounds are needed here, though for some reason it doesn&#8217;t like TexSubImage2D with BGRA data, but that&#8217;s not a big deal.  The Droid (OMAP3, PowerVR SGX) supports EXT_texture_format_BGRA8888 (note: different name, similar functionality), so that&#8217;s good, but it doesn&#8217;t support non power of two textures with ES1.1.  The Nexus One, on the other hand, supports neither BGRA nor NPOT textures.</p>
<p>I was about to start using OES_draw_texture as well, because that seemed like a potentially faster way to get what I want to happen &#8212; but the lack of BGRA support on the Nexus One made me turn to ES2, where I can do the RGBA-&gt;BGRA swizzle in the fragment shader.</p>
<h3>Undefined Symbols in GLESv2 Import Library</h3>
<p>More fun!  The Android r3 NDK includes GLESv2 support, yay!  The bad news is that libGLESv2.so includes an external reference to _ZN7android33egl_get_image_for_current_contextEPv (android::egl_get_image_for_current_context), which means you&#8217;ll get linker errors (or at least undefined symbol errors) if you try to link anything that&#8217;s not a shared library.  Conveniently, that&#8217;s what you need to produce with the NDK anyway, but if you have some helper command line tools along the way, they&#8217;ll fail.  The solution is to add -Wl,&#8211;allow-shlib-undefined to your binary compile/link step.</p>
<p>After that, this was fairly straightforward, though the SDK only grudgingly allows you to specify the necessary EGL tokens for GLES2; the code samples in the NDK all just provide explicit integer values for them inside the code.</p>
<h3>Choosing an EGLConfig</h3>
<p>This applies to both OpenGL ES 1 and OpenGL ES 2 on Android.  When creating an EGLSurface for a SurfaceView (take a look at how GLSurfaceView does it for the details), you have to get an EGLConfig that has an exact match for the number of red/green/blue/alpha bits as your surface.  There&#8217;s a format parameter to surfaceChanged that&#8217;s supposed to tell you the format of the surface.  However, it seems to always show up as &#8216;-1&#8242;, which according to PixelFormat.java, is &#8220;OPAQUE&#8221;.  That&#8217;s not very helpful.  Reading GLSurfaceView, it can show up as -2, which is TRANSPARENT.  So &#8212; you have to assume that if you have an OPAQUE surface format, it&#8217;ll be 5650, and if you have a TRANSPARENT format it&#8217;ll be 8888.  This is pretty silly, as there are PixelFormat constants for handy things like RGBA_8888, RGB_565, RGB_888, RGBA_5551, etc.  Why doesn&#8217;t SurfaceView send the actual format down?</p>
<p>The devices that I have seem pretty consistent at least with 565 for OPAQUE, so it works OK, but it&#8217;s not pretty, and will likely blow up spectacularly if anyone introduces, say, a large-display Android device that uses 24bpp color.</p>
<p>Another config issue is that some GPUs have some odd requirements for getting the most preformance; for example, as discovered via searching, the PowerVR SGX in the Droid really wants 24-bit depth, as it&#8217;s faster than 0 and 32.  The Tegra, on the other hand, doesn&#8217;t have 24bpp depth at all, only 0 or 16 (and I don&#8217;t think it cares one way or the other).  Not sure whether the GPU in the Nexus One cares or has a preference.  So, you have to search for a 24-bit depth config first, use it if it&#8217;s found, and then try 0 if not found.  I suppose an alternate approach might be to search for 16-bit depth, but that might give you 32-bit if that happens to be supported somewhere.</p>
<p>At the end of all of this though, I have an app that uses OpenGL ES 2 on three different Android devices (with three different GPUs).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/03/19/things-i-learned-today-android-opengl-edition-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a Caching Proxy Server for Web Demos</title>
		<link>http://blog.vlad1.com/2010/03/15/using_a_caching_proxy_server/</link>
		<comments>http://blog.vlad1.com/2010/03/15/using_a_caching_proxy_server/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 21:59:33 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=260</guid>
		<description><![CDATA[A while ago, Rob Arnold wrote a simple python caching proxy server for use with our Talos tests &#8212; the idea was that you&#8217;d run your test once against the proxy server in &#8220;record&#8221; mode, and then after that you can use the server for consistent local playback. I was giving some WebGL demos recently, [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, Rob Arnold wrote a simple python caching proxy server for use with our Talos tests &#8212; the idea was that you&#8217;d run your test once against the proxy server in &#8220;record&#8221; mode, and then after that you can use the server for consistent local playback.</p>
<p>I was giving some WebGL demos recently, and needed a way to have all the content from the web-hosted demos locally.  As anyone who&#8217;s tried to create a local cache of any &#8220;Web 2.0&#8243; app knows, it&#8217;s painful, given all the server requests, XMLHttpRequests, etc. that go on.  However, with the proxy server, this was actually ridiculously easy.</p>
<p>You can grab the proxy server here &#8212; it still lives in Mozilla CVS &#8212; <a href="http://mxr.mozilla.org/mozilla/source/testing/tools/proxyserver/proxyserver.py?raw=1">proxyserver.py</a>.  It works fine on Win32, OS X, and Linux.  On Win32, the python that&#8217;s part of mozilla-build works well.  Run it like this:</p>
<pre>python proxyserver.py</pre>
<p>and then in Firefox&#8217;s proxy settings (or the system proxy settings), set your HTTP proxy to <strong>localhost:8000</strong>.  You can change the port via a command line option.  Then, visit all the pages/sites that you want cached (don&#8217;t forget to shift-reload or clear Firefox&#8217;s cache beforehand to ensure that Firefox actually goes out to the network!).  After you&#8217;ve got everything going, restart the proxy server in local-only mode:</p>
<pre>python proxyserver.py -l</pre>
<p>&#8230; and make sure that your demos work.  You can also run without -l live, especially if you will have a network connection (even a slow one) to give you the option of going out to the network if necessary.  Also, if you want to copy the proxy cache to another machine, just copy <strong>proxy_cache.db </strong>that gets created in the same directory as proxyserver.py.</p>
<p>The proxy server currently supports HEAD and GET requests.  It doesn&#8217;t support POST, so if you have something that depends on POST, you&#8217;re out of luck.  It wouldn&#8217;t be too hard to add though; patches accepted if someone wants to tackle that.</p>
<p>With the proxy server, I was able to give a bunch of demos that made heavy use of XHR, including some that loaded video, without having to rely on a network or spend time downloading and fixing up URLs.  It really made demo prep much easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/03/15/using_a_caching_proxy_server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mjs: Simple Vector and Matrix Math for JS</title>
		<link>http://blog.vlad1.com/2010/02/05/mjs-simple-vector-and-matrix-math-for-js/</link>
		<comments>http://blog.vlad1.com/2010/02/05/mjs-simple-vector-and-matrix-math-for-js/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 09:04:19 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Canvas 3D]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[spidermonkey]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=253</guid>
		<description><![CDATA[One common thread running through the many different and interesting WebGL projects out there is that they all need to do vector and matrix math, do it quickly, and do it in JavaScript.  To date, developers have either rolled their own, or they&#8217;ve used Sylvester, a fairly featureful vector and matrix JavaScript library. One of [...]]]></description>
			<content:encoded><![CDATA[<p>One common thread running through the <a href="http://learningwebgl.com/blog/">many</a> <a href="http://www.c3dl.org/">different</a> and <a href="http://www.glge.org/">interesting</a> <a href="http://www.webgl.org/">WebGL</a> <a href="http://www.x3dom.org/">projects</a> out there is that they all need to do vector and matrix math, do it quickly, and do it in JavaScript.  To date, developers have either rolled their own, or they&#8217;ve used <a href="http://sylvester.jcoglan.com/">Sylvester</a>, a fairly featureful vector and matrix JavaScript library.</p>
<p>One of the problems with Sylvester is that while it&#8217;s fully featured (arbitrary NxN matrices and vectors can be created and manipulated), it suffers in performance because of it.  Since this is such a crucial part of a successful WebGL program, I&#8217;ve put together a small package that I&#8217;m calling <strong>mjs</strong>.</p>
<p><strong>mjs</strong> is designed around speed and simplicity.  For example, it doesn&#8217;t attempt to stuff vectors and matrices into JavaScript objects.  Because the language offers no operator overloading, there&#8217;s very little benefit in treating these types as discrete objects, and lots of performance and memory usage downsides.  Instead, it provides a set of functions for performing operations on vectors and matrices, which can be any array-like object.  For any function that returns a vector or matrix, an existing array can be passed in to take the result, or the function can create a new one.  Array reuse ends up being important because of the potential for expensive garbage collection churn eating away at performance.</p>
<p>Here&#8217;s a sample of the API:</p>
<pre>var r = M4x4.rotate(Math.PI/2, V3.$(0, 1, 0),  M4x4.I);</pre>
<p>Note that V3.$ and M4x4.$ are shorthand for creating a new V3 or M4x4 (I wanted to use V3() and M4x4(), but that didn&#8217;t work out too well since functions have a length property).  However, because all they return are just new array-like objects, you could also write:</p>
<pre>var r = M4x4.rotate(Math.PI/2, [0, 1, 0], M4x4.I);</pre>
<p>If the WebGL types are available, those will be used for newly created vectors/matrices.  They are a significant performance boost especially for repeated operations; but for specifying one-off vectors such as the above, literal array syntax is fine.</p>
<p>The rotate function internally makes a rotation matrix, and then multiplies it by the given matrix.  So the above could also be written as:</p>
<pre>var rotation = M4x4.makeRotate(Math.PI/2, [0, 1, 0]);
var r = M4x4.mul(M4x4.I, rotation);</pre>
<p>(The last line being redundant given that we&#8217;re multiplying by the identity matrix.)</p>
<p>All methods that return a vector or matrix take an optional final argument, that of an existing object to reuse.  For example:</p>
<pre>var m0 = M4x4.$();
r = M4x4.mul(someMatrixA, someMatrixB, m0);
// r == m0, so the assignment isn't necessary, but it's handy for chaining
// .... do something with r ...
r = M4x4.mul(someMatrixB, someMatrixC, m0);
// r == m0 still
// ... do something else with new results ...</pre>
<p>Without allocating any additional temporary objects.</p>
<p>As mentioned before, one of the goals of <strong>mjs</strong> is performance.  Matrix multiplication is one of the most common tasks, so here are some numbers comparing <strong>mjs</strong>, Sylvester, and native C code.  This was run on a Core i7 desktop using a local build of Spidermonkey, which included one patch that&#8217;s about to go into the tree that fixes the no-reuse tracing case.  (Without it, the no-reuse tracing case is much larger because it&#8217;s never actually jitted.)  The test is simple: it multiplies two matrices together in a loop 1,000,000 times.</p>
<table>
<tr>
<th>Test</th>
<th>Time</th>
</tr>
<tr>
<td>mjs, JIT, matrix reuse</td>
<td align="right">140ms</td>
</tr>
<tr>
<td>mjs, JIT, no reuse</td>
<td align="right">533ms</td>
</tr>
<tr>
<td>Sylvester, JIT, no reuse</td>
<td align="right">5,280ms</td>
</tr>
<tr>
<td>mjs, no JIT, matrix reuse</td>
<td align="right">25,833ms</td>
</tr>
<tr>
<td>mjs, no JIT, no reuse</td>
<td align="right">26,681ms</td>
</tr>
<tr>
<td>Sylvester, no JIT, no reuse</td>
<td align="right">41,996ms</td>
</tr>
<tr>
<td>Native C++, SSE2, matrix reuse</td>
<td align="right">71ms</td>
</tr>
<tr>
<td>Native C++, SSE2, no reuse</td>
<td align="right">142ms</td>
</tr>
</table>
<p>(I also have numbers for MSVC without the SSE2 compile flag, but the numbers vary greatly depending on whether the values eventually go to infinity or not; if the values end up trending towards 0, the non-SSE2 code tends to win at around 52ms vs. 71ms; if the values trend to infinity, the non-SSE2 code takes around 11,000ms!)</p>
<p>Those numbers are pretty encouraging &#8212; having native code be only 2x as slow for something like this is pretty nice to see.  Granted, this is only a very isolated test, and I&#8217;m sure there are some tricks to optimizing the native code case (it&#8217;s currently just a fully unrolled set of multiplies and adds).  The &#8220;no JIT&#8221; case is less nice, but I&#8217;m sure that our Jaegermonkey folks will be all over this testcase (right, guys?).  In any case, ideally most WebGL rendering loops will be fully traced in Firefox, so it would be less of an issue.</p>
<p><strong>mjs</strong> is still very much a work in progress; it&#8217;s missing a test suite and a whole bunch of features.  You can find it hosted at Google Code, at <a href="http://webgl-mjs.googlecode.com/">webgl-mjs</a>.  (Side note: I couldn&#8217;t just call the project mjs because a project called mjs was abandoned on Sourceforget 5 years ago, and Google Code complained.)  There&#8217;s also some documentation, <a href="http://webgl-mjs.googlecode.com/hg/docs/files/mjs-js.html">viewable online here</a>.</p>
<p>Bugs and contributions welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/02/05/mjs-simple-vector-and-matrix-math-for-js/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
