<?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; Firefox</title>
	<atom:link href="http://blog.vlad1.com/category/firefox/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>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>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>
		<item>
		<title>Android Progress: More Pixels Edition</title>
		<link>http://blog.vlad1.com/2010/02/02/android-progress-more-pixels-edition/</link>
		<comments>http://blog.vlad1.com/2010/02/02/android-progress-more-pixels-edition/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 00:29:42 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=247</guid>
		<description><![CDATA[It&#8217;s been a while since I posted a progress update (or really any blog post, ahem), but porting Firefox/Fennec to Android is progressing at a good clip. After working out a few kinks (and setting the all-important &#8220;you&#8217;re allowed to touch the network&#8221; permission), I just got our first page load: Mouse events sort of [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I posted a progress update (or really any blog post, ahem), but porting Firefox/Fennec to Android is progressing at a good clip.  After working out a few kinks (and setting the all-important &#8220;you&#8217;re allowed to touch the network&#8221; permission), I just got our first page load:</p>
<p style="text-align: center;"><a href="http://people.mozilla.com/~vladimir/misc/r4.png"><img class="aligncenter" title="Gecko in Android" src="http://people.mozilla.com/~vladimir/misc/r4.png" alt="" width="682" height="426" /></a></p>
<p style="text-align: left;">Mouse events sort of work, toplevel windows sort of work, keyboard doesn&#8217;t work yet but shouldn&#8217;t be hard to hook up.  This is running in an emulator at the moment for ease of debugging, but it&#8217;s working just fine on physical hardware as well.</p>
<p style="text-align: left;">You&#8217;ll note that this is the full Firefox interface, and not the Fennec/Firefox Mobile UI; we&#8217;re testing with the full interface because it&#8217;s significantly more complex than the mobile UI and stresses Gecko much more.  So, if the full UI works, then Fennec should work fine as well.  Given the interest in Android on netbook and tablet devices, an updated version of the full Firefox UI might find a home on some of these.  Android has been pretty great to work with so far; it&#8217;s a bit unusual platform for us due to its Java core, but with the NDK we&#8217;re able to bridge things together without many problems.</p>
<p style="text-align: left;">We&#8217;re still a ways  to go before any kind of usable alpha release, but we&#8217;re certainly one step closer.  We&#8217;ll also be able to accelerate our progress now that we have some of the basic scaffolding in place.  I know I&#8217;m looking forward to running Fennec on my Droid, and there are tons of Android devices coming out that should be great platforms for Fennec.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/02/02/android-progress-more-pixels-edition/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>WebGL Draft Goes Public</title>
		<link>http://blog.vlad1.com/2009/12/10/webgl-draft-goes-public/</link>
		<comments>http://blog.vlad1.com/2009/12/10/webgl-draft-goes-public/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 22:10:17 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Canvas 3D]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[canvas3d]]></category>
		<category><![CDATA[khronos]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=240</guid>
		<description><![CDATA[I&#8217;m pretty excited to have the WebGL draft spec available for review and comments today.  There&#8217;s still plenty of time for feedback, but we&#8217;re far enough along to be able to solicit meaningful feedback.  There are multiple implementations, which is a much better state than the early Canvas 3D work where things only worked during [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.khronos.org/webgl/"><img class="alignleft size-full wp-image-241" style="border: none;" title="WebGL" src="http://blog.vlad1.com/wp-content/uploads/2009/12/webgl_200px.gif" alt="WebGL" width="163" height="75" /></a>I&#8217;m pretty excited to have the WebGL draft spec available for review and comments today.  There&#8217;s still plenty of time for feedback, but we&#8217;re far enough along to be able to solicit meaningful feedback.  There are multiple implementations, which is a much better state than the early Canvas 3D work where things only worked during a full moon after saying &#8220;OpenGL&#8221; three times backwards into your monitor!</p>
<p>We&#8217;re actively working through remaining warts and edge cases (and they are a lot of them!).  Take a look at the official <a href="http://www.khronos.org/webgl/">Khronos WebGL landing page</a> and <a href="http://hacks.mozilla.org/2009/12/webgl-draft-released-today/">Arun&#8217;s blog post</a> for more information, including where to go to sign up for the public mailing list and for a set of resources about WebGL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2009/12/10/webgl-draft-goes-public/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heads Up: WebGL Canvas*Array renamed to WebGL*Array</title>
		<link>http://blog.vlad1.com/2009/12/02/heads-up-webgl-canvasarray-renamed-to-webglarray/</link>
		<comments>http://blog.vlad1.com/2009/12/02/heads-up-webgl-canvasarray-renamed-to-webglarray/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 21:48:19 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Canvas 3D]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=237</guid>
		<description><![CDATA[I just checked in a patch from Mark that renames WebGL&#8217;s Canvas*Array objects to be WebGL*Array, to match the current state of the spec.  The APIs remain the same, so it should be a matter of search-and-replace to update.  Should show up in tomorrow&#8217;s nightly builds of Firefox.]]></description>
			<content:encoded><![CDATA[<p>I just checked in a patch from Mark that renames WebGL&#8217;s <a href="http://blog.vlad1.com/2009/11/06/canvasarraybuffer-and-canvasarray/">Canvas*Array objects</a> to be WebGL*Array, to match the current state of the spec.  The APIs remain the same, so it should be a matter of search-and-replace to update.  Should show up in tomorrow&#8217;s nightly builds of Firefox.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2009/12/02/heads-up-webgl-canvasarray-renamed-to-webglarray/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebGL Goes Mobile</title>
		<link>http://blog.vlad1.com/2009/12/01/webgl-goes-mobile/</link>
		<comments>http://blog.vlad1.com/2009/12/01/webgl-goes-mobile/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 18:29:52 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Canvas 3D]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=209</guid>
		<description><![CDATA[One of the goals of WebGL was always to enable the functionality on both desktop and mobile devices.  This is one of the reasons why OpenGL ES 2.0 was chosen as a starting point for the capabilities exposed by the spec. We&#8217;ve had support for WebGL in Firefox desktop nightlies for a few weeks now, [...]]]></description>
			<content:encoded><![CDATA[<p>One of the goals of <a href="http://en.wikipedia.org/wiki/WebGL">WebGL</a> was always to enable the functionality on both desktop and mobile devices.  This is one of the reasons why OpenGL ES 2.0 was chosen as a starting point for the capabilities exposed by the spec.</p>
<p>We&#8217;ve had support for WebGL in Firefox desktop nightlies for a few weeks now, but soon I hope to have it enabled on Firefox for mobile devices (code name Fennec) as well.  Jay demonstrated some simple demos working on <a href="http://maemo.nokia.com/n900/">Nokia&#8217;s N900</a> at the ARM techcon3 <span style="text-decoration: line-through;">today</span> a few weeks ago (took a while to get the video done!), and I&#8217;ve grabbed a quick video showing things in action.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="580" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Ly65aWGZn1w&amp;hl=en_US&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="580" height="360" src="http://www.youtube.com/v/Ly65aWGZn1w&amp;hl=en_US&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p style="text-align: left;">This should be showing up in Firefox for mobile devices nightly builds, so we&#8217;ll see some more interesting things running on phones soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2009/12/01/webgl-goes-mobile/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
