<?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ć</title>
	<atom:link href="http://blog.vlad1.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vlad1.com</link>
	<description>Words</description>
	<lastBuildDate>Thu, 06 Oct 2011 02:40:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Looking at Java NIO Buffer performance</title>
		<link>http://blog.vlad1.com/2011/10/05/looking-at-java-nio-buffer-performance/</link>
		<comments>http://blog.vlad1.com/2011/10/05/looking-at-java-nio-buffer-performance/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 02:40:14 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=399</guid>
		<description><![CDATA[While starting to convert much of our IO to using nio byte buffers, with an eventual goal in pushing that further up into the application, I decided to investigate in some more detail performance. I&#8217;d seen some blog posts that claimed that performance wasn&#8217;t great, in particular a very old blog post from 2004. That [...]]]></description>
			<content:encoded><![CDATA[<p>While starting to convert much of our IO to using nio byte buffers, with an eventual goal in pushing that further up into the application, I decided to investigate in some more detail performance.  I&#8217;d seen some blog posts that claimed that performance wasn&#8217;t great, in particular <a href="http://www.jroller.com/cpurdy/entry/raw_nio_performance">a very old blog post from 2004</a>.  That post included a simple benchmark, which I grabbed, converted to use Int buffers, dropped the count to 10,000,000 int values, and ran it.  The source is available as <a href="https://gist.github.com/1266342#file_niotest.java">niotest.java</a>.  The results weren&#8217;t encouraging:</p>
<pre>  <strong>Java Version      1.6        1.7</strong>
  array[] put      26 ms      31 ms
  absolute put    129 ms     130 ms
  relative put    130 ms     132 ms
  array[] get      20 ms      19 ms
  absolute get    116 ms     119 ms
  relative get    130 ms     137 ms</pre>
<p>Not only was there no really visible perf changes between Java 1.6 and 1.7, using the nio buffers was 4x-6x slower than regular java arrays!  I wrote a quick equivalent benchmark in JavaScript, using <a href="http://www.khronos.org/registry/typedarray/specs/latest/">Typed Arrays</a>, and originally saw numbers in the 11ms range.  (Note: the original benchmark numbers aboe were inthe 300ms range for nio arrays, before a laptop suspend/unsuspend &#8212; I incredulously tweeted the 30x difference, and then went about cleaning up the benchmarks.  I can&#8217;t reproduce either result now; the Java version got faster, and the JavaScript version got slower.)  The JS benchmark (source code <a href="https://gist.github.com/1266346#file_buftest.html">buftest.html</a>) gives about 65ms for writing and 40ms for reading.  That still seemed faster, and I set about writing this blog post.</p>
<p>As part of that, I decided to clean up the benchmark code and put everything together in a nice package.  The source for the new benchmark is <a href="https://gist.github.com/1266342#file_array_benchmark.java">ArrayBenchmark.java</a>.  Like the original, it works on arrays/buffers of 10,000,000 integers, first writing each element (with just its index) and then reading each element in the get operation.  The additional &#8220;copy into&#8221; benchmarks time how long it takes to copy all the ints into an existing int[] array.  Here are the results:</p>
<pre>                               <strong>   Java 1.6       Java 1.7</strong>
===== native java int[] array
                           put:  27.971961 ms   42.464894 ms
                           get:  32.949032 ms   14.826696 ms
                     copy into:  20.069191 ms   15.853778 ms
===== nio heap buffers
                           put: 839.730766 ms   57.876372 ms
                put (relative): 844.618171 ms   80.951102 ms
                           get: 742.287840 ms   80.578592 ms
                get (relative): 759.317101 ms   79.563458 ms
                     copy into: 769.494235 ms   91.685437 ms
===== nio direct buffers
                           put: 161.480338 ms   31.951206 ms
                put (relative): 170.194344 ms   47.541457 ms
                           get: 179.621322 ms   18.913808 ms
                get (relative): 164.425689 ms   29.387186 ms
                     copy into:  21.940450 ms   16.936357 ms
===== custom buffers
                           put: 151.095845 ms   48.125012 ms
                 put unchecked: 148.538301 ms   51.241096 ms
                           get: 146.243837 ms   36.636723 ms
                 get unchecked: 138.765277 ms   31.641897 ms
                     copy into:  41.643050 ms   20.206091 ms
        copy into (copyMemory): N/A             16.845686 ms</pre>
<p>These numbers show a significant improvement in Java 1.7!  Direct buffers are roughly about as fast as regular arrays, which is what I had hoped to see originally.  The &#8220;custom buffers&#8221; section is a hand-rolled integer buffer class that uses Unsafe.getInt/putInt without much of the additional nio buffer machinery or abstractions, to see how much that was contributing to overhead.  It&#8217;s noticable in Java 1.6, but in Java 1.7 the original nio buffers win handily, even against &#8220;unchecked&#8221; versions of get/put that don&#8217;t do any bounds checking.  I also added heap (non-direct) buffers, to see if there was any truth to a claim I read regarding mixing direct and non-direct buffers causing an overall slowdown, because then there would be two implementations of the abstract parent class, and the VM couldn&#8217;t optimize the virtual calls.  That doesn&#8217;t seem to be the case any more &#8212; the JIT doesn&#8217;t care.</p>
<p>But, I am now very confused why the original benchmark code and the new code give such different results.  The normal int[] ut is down to 42ms, slower than the 31ms in in the original benchmark, and slower still than the 27ms that the same benchmark gets in Java 1.6.  The other numbers are all much better though &#8212; compare, for example, direct buffer absolute &#8220;get&#8221; performance &#8212; 119ms in the first benchmark, 19ms in the second.  This is a 6x speed difference.  The same compiler and JVM are used for both.  I even added a &#8216;mixed&#8217; set to the new benchmark, that does the operations in the exact same order as the first one (interlaving operations on arrays and int buffers), and it didn&#8217;t matter.</p>
<p>The new benchmark numbers are really encouraging, and mean that we&#8217;re going to probably push the nio buffers into many places, simplifying our interaction both with IO, OpenGL, algorithms implemented in JNI, etc. as well as letting us move the bulk of our large data out of the Java heap.  However, I&#8217;d like to understand why the two benchmarks give such vastly different performance results.  I&#8217;ve stared at the source for a while, and I&#8217;m virtually certain that they&#8217;re doing the same operations, on identically-sized arrays.  Can someone explain the overall slowness of the first benchmark?  Why didn&#8217;t the numbers change hardly at all between Java 1.6 and 1.7?  Why are the 1.6 numbers in the second benchmark slower than the 1.6 numbers in the first?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2011/10/05/looking-at-java-nio-buffer-performance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What I&#8217;ve Been Up To</title>
		<link>http://blog.vlad1.com/2011/06/10/what-ive-been-up-to/</link>
		<comments>http://blog.vlad1.com/2011/06/10/what-ive-been-up-to/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 17:19:06 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=387</guid>
		<description><![CDATA[The last post here was about leaving Mozilla, and I mentioned a tiny bit about where I was going and what I&#8217;ll be working on. Then there was radio silence for a few months. So, what have I been up to? First off, we launched WebGL 1.0 at GDC 2011. I was serving as chair [...]]]></description>
			<content:encoded><![CDATA[<p>The last post here was about leaving Mozilla, and I mentioned a tiny bit about where I was going and what I&#8217;ll be working on.  Then there was radio silence for a few months.  So, what have I been up to?</p>
<p>First off, we launched <a href="http://webgl.org/">WebGL 1.0</a> at GDC 2011.  I was serving as chair at the time, though after the launch Ken Russell at Google took over as I was leaving Mozilla.   I haven&#8217;t been as involved in WebGL (or Mozilla at all, really) over the past few months as I&#8217;d like to be, because of a number of new job things and moving.  I hope to get back into it as things settle down more, though I&#8217;ve been saying that for the past month.  Soon!</p>
<p>I spent the first two months in Australia, at the headquarters of DownUnder Geosolutions in <span style="text-decoration: line-through;">happening</span> <span style="text-decoration: line-through;">exotic</span> <span style="text-decoration: line-through;">vibrant</span> sunny Perth.  There was a lot of crash-course geophysics instruction going on.  I basically inhaled <a href="http://www.amazon.com/3-D-Seismic-Interpretation-M-Bacon/dp/0521710669/">3-D Seismic Interpretation</a>, and asked lots of dumb questions.  I can now reasonably hold a conversation about 2-D, 3-D, and 4-D data sets; TWT vs. TVDSS (not to be confused with TWSS); stacking; horizons; faults; wells and well logs; etc.  (At least, I can fake knowing what I&#8217;m talking about, which is often all that matters.)</p>
<p>The app itself, <a href="http://www.dugsw.com/duginsight/">DUG Insight</a> is really all about data visualization, and UI to get at facets of the data in a reasonable way.  We&#8217;re nowhere near where we want to be with the UI, but in many ways we&#8217;re already light years ahead of the competition &#8212; which often looks <a href="http://blog.vlad1.com/wp-content/uploads/2011/06/microsoft-word-toolbars-crazy.png">something like this</a>.</p>
<p>One of the first things I worked on was adding some 3D visualization to well log data.  This is basically data gathered along a well bore by instruments that are either part of the drilling package or are otherwise sent down.  It&#8217;s often the only &#8220;truth&#8221; data that you have that&#8217;ll tell you exactly what&#8217;s down there.  When showing this data in 3D, it&#8217;s nice to be able to vary the thickness of the cylinder based on the data, to give another visual cue along with an applied colourbar.  The result:</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2011/06/20110602154325467.png"><img class="aligncenter size-full wp-image-389" title="20110602154325467" src="http://blog.vlad1.com/wp-content/uploads/2011/06/20110602154325467.png" alt="" width="366" height="240" /></a></p>
<p>There are three wells visible here along with their logs, and some seismic data that I made translucent for the screenshot.  The tricky thing here is that the data is quite high frequency, and is often very finely sampled.  Very small spikes or troughs can be significant, but normal data minification often just smooths them away.  We don&#8217;t have this solved in the 3D view yet, but in another view I did some work to attempt to show at least the local maxima that contribute to each pixel:</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2011/06/well-corr-minmax.png"><img class="aligncenter size-full wp-image-388" title="well-corr-minmax" src="http://blog.vlad1.com/wp-content/uploads/2011/06/well-corr-minmax.png" alt="" width="464" height="276" /></a></p>
<p>The right is a zoomed in version of the left data.  On the right, we can represent all the data accurately, since we have more pixels available than we have actual samples.  On the left, though, more than one data sample contributes to each vertical pixel.  The gray bars indicate maximum values for all data points that contribute to each pixel.  The difference can be pretty big; here&#8217;s a side-by-side render of the same data, one with the gray max values and one without:</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2011/06/well-corr-minmax-2.png"><img class="aligncenter size-full wp-image-390" title="well-corr-minmax-2" src="http://blog.vlad1.com/wp-content/uploads/2011/06/well-corr-minmax-2.png" alt="" width="209" height="119" /></a></p>
<p>There are other options here, and we&#8217;re still working on figuring out how to expose them to the user (for example, drawing a line down the average value and drawing a bar from min to max).</p>
<p>Other stuff I&#8217;ve worked on so far has been much less visual.  The codebase is somewhat old, and was often written for correctness and/or purity, and less so for performance and ease of use.  For example, we interpolate lots of data; our current interpolators tend to go through a number of function calls *per sample* and do no caching even though we&#8217;ll often interpolate multiple samples between the same two adjacent data lines.  This is on the list of things to correct, because, well, <a href="http://www.youtube.com/watch?v=VmarNEsjpDI">babytown frolics</a>.  There will also be a lot more 3D visualization work done as soon as our next release ships.</p>
<p>In other news, I also drove cross-country from the San Francisco Bay Area to Toronto, where I&#8217;m now living.  It should have been a lot more fun, but the various camping/hiking I had planned along the way got cancelled because of bad weather&#8230; so I just drove straight through, taking about 4.5 days to do the drive.  The <a href="http://rd.io/x/QJcKL0KT9A">Cross-country Road Trip playlist on rdio</a> that friends helped me put together was pretty awesome&#8230; listened to it straight through, probably ended the drive with a few hours to go.  There&#8217;s some great music there, along with a few questionable choices which made me laugh during the trip (rick rolled driving into Colorado; the Oregon State Song came up at some point; etc.).</p>
<p>Last but not least, DUG is hiring in Toronto &#8212; if you have some data viz, UI, or rockstar Java chops, send me an email (vladimir at pobox dot com).  We have just about every interesting software engineering problem, so there&#8217;s a lot of good challenges to tackle.  The Toronto team is currently small (just three of us), in a great brick-and-beam building near Spadina and Richmond; it&#8217;s a pretty fun environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2011/06/10/what-ive-been-up-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving On</title>
		<link>http://blog.vlad1.com/2011/02/15/moving-on/</link>
		<comments>http://blog.vlad1.com/2011/02/15/moving-on/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 04:20:05 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=382</guid>
		<description><![CDATA[I&#8217;ve recently made the decision to leave Mozilla for various reasons, largely because I&#8217;ve been wanting to do something different. Here are some thoughts on this. I became involved in Firefox and the Mozilla community when I was suckeredtalked into fixing a bug &#8212; a bug that involved RDF, bookmarks, and the template builder. (Thankfully, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently made the decision to leave Mozilla for various reasons, largely because I&#8217;ve been wanting to do something different.  Here are some thoughts on this.</p>
<p>I became involved in Firefox and the Mozilla community when I was <strike>suckered</strike>talked into fixing a bug &#8212; a bug that involved RDF, bookmarks, and the template builder.  (Thankfully, all three of those things &#8212; RDF, old bookmarks, template builder &#8212; have almost been completely excised from Firefox.)  Somehow I ended up sticking around to fix more bugs and get involved in bigger projects, from working with Stuart to <a href="http://blog.vlad1.com/2007/12/11/graphics-in-mozilla/">rework our graphics engine</a> up to <a href="http://blog.vlad1.com/2010/02/02/android-progress-more-pixels-edition/">getting the Android port going</a>.</p>
<p>One of the things that I had as a goal when I started at Mozilla was to bring 3D graphics to the web.  It took a bit longer than I expected (as usual), but with <a href="http://www.webgl.org/">WebGL</a>, we now have a solid foundation for doing all sorts of 3D apps via the web.  Many things had to come together to enable that: fast JavaScript, improvements to overall rendering architecture, emphasis on mobile, etc. all contributed to the viability of WebGL.  Over the years, I&#8217;ve had the opportunity to work on many projects in those areas with many talented people, and the experiences will certainly help in future efforts.</p>
<p>So, what am I doing next?  <a href="http://www.dugsw.com">Something entirely different</a>.  I&#8217;ll be doing software in a totally different industry, joining some friends in bringing some disruptive innovation there.  I&#8217;ll still be writing software, though with a much smaller team &#8212; something that I&#8217;ve come to enjoy, as being small and scrappy has a lot of advantages and is a lot of fun.  There&#8217;s a lot of interesting technical challenges, mainly related to dealing with large volumes of data (multiple terabytes not being uncommon) &#8212; processing, visualization, analysis.  You&#8217;ll also likely see me hacking various bits in my own spare time, whether in Mozilla, web apps, or mobile apps.  I plan on continuing to blog about these topics.</p>
<p>For WebGL in particular, I&#8217;ll be around to launch the initial version of the spec, and plan on continuing to be involved in the standards group.  I might not be hacking on Mozilla&#8217;s implementation as frequently, but it&#8217;ll be in good hands.</p>
<p>Thank you to all the people that I&#8217;ve had a chance to work with and learn from over the past 5 (almost 6!) years.  I&#8217;ll still be around irc and other forums so won&#8217;t be pulling a disappearing act any time soon, and I&#8217;m looking forward to seeing Firefox 4 out there!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2011/02/15/moving-on/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>WebGL in Firefox 4 Beta 8</title>
		<link>http://blog.vlad1.com/2010/12/21/webgl-in-firefox-4-beta-8/</link>
		<comments>http://blog.vlad1.com/2010/12/21/webgl-in-firefox-4-beta-8/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 19:00:08 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Canvas 3D]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=355</guid>
		<description><![CDATA[One of the parts of Firefox 4 that I&#8217;m excited about is support for WebGL, a standard for accelerated 3D rendering on the web. We&#8217;ve been working on this for quite a while, and I&#8217;ve been doing experiments with a similar kind of 3D support for a few years now. With the upcoming release of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the parts of Firefox 4 that I&#8217;m excited about is support for WebGL, a standard for accelerated 3D rendering on the web.  We&#8217;ve been working on this for quite a while, and I&#8217;ve been doing experiments with a similar kind of 3D support for a few years now.  With the upcoming release of Firefox 4 Beta 8, WebGL support is starting to firm up.</p>
<h2>What is WebGL?</h2>
<p><a href="http://webgl.org/">WebGL</a> allows web developers to take advantage of the 3D capabilities of modern video cards to add 3D displays to their web applications. Apps that would have been possible only on the desktop or with plugins become possible in any modern browser that supports WebGL: 3D games, interactive product displays, scientific and medical visualization, shared virtual environments, and 3D content creation all become possible on the web.</p>
<p>For users, this means a more interactive and visually interesting web. It means having access to a wider range of applications and experiences on any device that supports the full web, instead of being limited to specific devices or platforms.</p>
<p>WebGL is being developed within the Khronos Group, the same group responsible for OpenGL and OpenGL ES.  Members of the WebGL group include Mozilla, Google, Opera, and Apple, as well as a number of hardware vendors who are interested in making sure that WebGL content can run well on both desktop and mobile hardware.  There&#8217;s a lot of support for WebGL!</p>
<p>I recently gave a talk at NVidia&#8217;s GPU Technology Conference about WebGL.  The <a href="http://nvidia.fullviewmedia.com/gtc2010/0921-a8-2113.html">video stream is available</a> (though sadly not using HTML5 video!), and it&#8217;s a good (though technical) overview of WebGL.</p>
<h2>Let me check out some demos!</h2>
<p>Here&#8217;s a couple of demos showcasing WebGL technology by Mozilla, Google, and others.</p>
<p>Some platform-specific notes: WebGL is currently disabled on Linux due to some build issues; it should be getting re-enabled in beta 9.  For Windows users, you may need to install the <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=2da43d38-db71-4c1b-bc6a-9b6652cd92a3&amp;displaylang=en">DirectX Runtime</a> in case these demos don&#8217;t work for you or if they have glitches &#8212; this allows Firefox to use an alternate rendering path that might be better supported on your system, especially on systems with Intel GPUs.  We&#8217;re working on removing the need for this separate install in a future build.</p>
<table class="aligncenter" border="0">
<tbody>
<tr>
<td>
<p><div id="attachment_359" class="wp-caption alignnone" style="width: 210px"><a href="http://videos.mozilla.org/serv/mozhacks/flight-of-the-navigator/" target="_blank"><img class="size-full wp-image-359 " title="Flight of the Navigator" src="http://blog.vlad1.com/wp-content/uploads/2010/12/fotn.png" alt="Flight of the Navigator" width="200" height="200" /></a><p class="wp-caption-text">Flight of the Navigator</p></div></td>
<td>
<p><div id="attachment_360" class="wp-caption alignnone" style="width: 210px"><a href="http://bodybrowser.googlelabs.com/" target="_blank"><img class="size-full wp-image-360" title="Body Browser" src="http://blog.vlad1.com/wp-content/uploads/2010/12/bodybrowser.png" alt="Body Browser" width="200" height="200" /></a><p class="wp-caption-text">Body Browser by Google</p></div></td>
<td>
<p><div id="attachment_358" class="wp-caption alignnone" style="width: 210px"><a href="http://webglsamples.googlecode.com/hg/aquarium/aquarium.html" target="_blank"><img class="size-full wp-image-358 " title="WebGL Aquarium" src="http://blog.vlad1.com/wp-content/uploads/2010/12/aquarium.png" alt="WebGL Aquarium" width="200" height="200" /></a><p class="wp-caption-text">WebGL Aquarium</p></div></td>
</tr>
</tbody>
</table>
<p>Check out Dave&#8217;s post for more <a href="http://vocamus.net/dave/?p=1233">details about the Flight of the Navigator</a> demo.  You can find many more projects and demos using WebGL on the web and linked from <a href="http://webgl.org">webgl.org</a> &#8212; for example, some other great examples are a <a href="http://www.3dtin.com/" target="_blank">web-based 3D editor called 3DTin</a> and <a href="http://www.ibiblio.org/e-notes/webgl/waves/annihilation.html" target="_blank">a vortex/anti-vortex annihilation simulation</a>,</p>
<h2>Give me more technical details!</h2>
<p>WebGL brings the OpenGL ES 2.0 API to the HTML5 Canvas element.  3D content is confined to the canvas, but the canvas follows normal HTML compositing rules.  For example, a 2D UI can be layered on top of the 3D scene using normal CSS mechanisms, and content underneath the canvas will show through transparent portions.  In addition, CSS properties can be applied to the canvas itself, for effects like fading the entire scene in or out.</p>
<p>The WebGL API interacts well with the rest of the web platform; specifically, support is provided for loading 3D textures from HTML images or videos, and keyboard and mouse input is handled using familiar DOM events.</p>
<h2>As a developer, how do I learn more about WebGL?</h2>
<p>WebGL is based on <a href="http://www.khronos.org/opengles/2_X/">OpenGL ES 2.0</a>, which just so happens to be the same 3D API used for Android and iOS development, as well as being based on the desktop OpenGL API.  Many resources available for ES 2.0 development translate almost directly to WebGL development.</p>
<p>Unlike desktop or mobile OpenGL development, it&#8217;s very easy to get started with WebGL.  Some simple HTML and JS content lets you immediately start writing WebGL code.  A number of tutorials already exist that focus on WebGL; you can take a look at <a href="http://learningwebgl.com/blog/?p=28">Learning WebGL&#8217;s lessons</a> to help you get started.</p>
<p>Here are some web resources with more information:</p>
<ul>
<li><a href="http://webgl.org/">webgl.org</a> &#8212; official WebGL page, including specification and resource links</li>
<li><a href="http://learningwebgl.com/">learningwebgl.com</a> &#8212; blog with regular updates on WebGL happenings</li>
</ul>
<h2>Future Work</h2>
<p>WebGL focuses on OpenGL ES 2.0 feature compatibility to ensure content compatibility with mobile devices.  However, ES 2.0 is behind the latest advances on the desktop today.  In the future, various desktop features may become available in WebGL in the form of extensions.</p>
<p>There&#8217;s still some work to do on the Firefox side as well, in particular removing some performance bottlenecks on Windows when we&#8217;re using ANGLE for Direct3D compatibility.</p>
<h2>Wrap up</h2>
<p>WebGL will enable web developers to create new experiences for their users.  As with any new technology, initial experimentation will lead to developers understanding better how to fully leverage WebGL. There&#8217;s already tremendous interest in WebGL, as can be seen by the wealth of frameworks and samples, even before WebGL has been released as part of any final shipping browser version!  By including WebGL in Firefox, and along with our work on HTML5 video and audio support (including direct audio data access), Firefox supports a full set of web<br />
technologies for building rich and compelling applications on the web.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/12/21/webgl-in-firefox-4-beta-8/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using Adobe Lightroom with Dropbox</title>
		<link>http://blog.vlad1.com/2010/11/20/using-adobe-lightroom-with-dropbox/</link>
		<comments>http://blog.vlad1.com/2010/11/20/using-adobe-lightroom-with-dropbox/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 21:51:27 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[lightroom]]></category>
		<category><![CDATA[photography]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=352</guid>
		<description><![CDATA[I&#8217;ve often been frustrated with the lack of a good solution for syncing a photo library amongst multiple computers.  Typically, I only have my laptop with me when I take photos, especially on a trip.  When I get back home, I want to sort and edit on a grown-up computer.  None of the photo management [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve often been frustrated with the lack of a good solution for syncing a photo library amongst multiple computers.  Typically, I only have my laptop with me when I take photos, especially on a trip.  When I get back home, I want to sort and edit on a grown-up computer.  None of the photo management tools seem to have any kind of support for this: Lightroom, Aperture, Bridge, etc. all seem to be designed for single computer usage.  Bridge has some allowance for using Adobe&#8217;s versioning stuff, but it seemed fairly complex to set up, and it wasn&#8217;t clear if it could do what I wanted anyway.</p>
<p>I recently became a fan of <a href="http://www.dropbox.com/">Dropbox</a>; it&#8217;s fantastic for file sharing and syncing amongst a bunch of computers and phones.  (If you decide to try it out, <a href="http://www.dropbox.com/referrals/NTg1NTk1MDM5?src=7">use this referral link</a> so that I get some extra space!)  I started wondering if I could use Dropbox to sync the Lightroom catalog.  This blog is a set of instructions on how to do just that, and also how to set up your photos so that you can easily migrate them between computers, or keep a backup on one or more hard drives.</p>
<h3>Moving your Lightroom catalog to Dropbox</h3>
<p>This one&#8217;s pretty simple.  First, install the latest version of <a href="http://forums.dropbox.com/tags.php?tag=beta">Dropbox 0.8 from their beta forums</a>.  0.8 has one feature that makes this much easier and useful &#8212; you can set it to ignore a set of folders for syncing.  This will become important in a second.</p>
<p>After you have Dropbox installed, simply take your main Lightroom catalog file (or multiple ones, these instructions work equally well for multiple catalogs) to somewhere inside your Dropbox folder.  I have a Lightroom folder inside Dropbox that has all my catalogs.</p>
<p>Open the catalog you just moved; Lightroom should start up, and all your data will be there.  However, if you go back to your Dropbox folder, you&#8217;ll see that Lightroom created another folder to store previews alongside your catalog.  For example, if your catalog is called &#8220;Lightroom 3 Catalog&#8221;, you should see &#8220;Lightroom 3 Catalog Previews.lrdata&#8221;.  This is the folder that we don&#8217;t want sync&#8217;d &#8212; it can get quite large, and there&#8217;s no reason to synchronize it.  Open Dropbox preferences (on Windows, this will be from the Dropbox icon in your system tray; I&#8217;m not sure how to do it on Mac), select Advanced, and click on Selective Sync.  Navigate to where your catalog is, and uncheck the Preview folder.</p>
<p>And that&#8217;s it.  Your other computers should have gotten a copy of your catalog, and you can open them there and work from the same set of data.  However, note that <em>only one computer can have the catalog open at a time</em>.  Lightroom creates a lock file which gets sync&#8217;d, but you can run into problems if you modify the catalog from two different computers while they&#8217;re both disconnected.  If you get into this state, you&#8217;ll have to do some merging of data just as if you had two independent catalogs.  Just get into the habit of closing Lightroom when you&#8217;re done with it on any computer and you&#8217;ll be fine.  (Or, if you&#8217;re disconnected for a while with a laptop, only use Lightroom there and connect it to the network before opening up the catalog on any other computers.)</p>
<p>However, this doesn&#8217;t get your photos to those other computers.  Ideally, you want Lightroom to not care what computer it&#8217;s on.</p>
<h3>Making your photos available to multiple computers</h3>
<p><em>Note: this section is written with Windows users in mind.  If you&#8217;re a Mac user, you can do the same thing via symlinks, but I don&#8217;t have detailed instructions here.</em></p>
<p>You can do this by making sure that the photos are always in the same location, no matter what computer you&#8217;re on.  The simplest way is to make sure they&#8217;re always in the same place &#8212; for example, &#8220;C:\Photos&#8221;.  That becomes somewhat inflexible, though.  For example, you may want to keep all your photos on a large external hard drive, but only keep a local cache of your most recent work to save disk space.</p>
<p>Enter the <em>subst</em> Windows utility.  <em>subst</em> lets you assign a drive letter to any location on any drive, and modify the location it points to at will.  For example, typing &#8220;<em>subst p: d:\storage\photos</em>&#8221; in the command prompt will make the P: drive show the contents of D:\Storage\Photos.  Not a fan of the command prompt?  You may want to use <a href="http://www.ntwind.com/software/utilities/visual-subst.html">Visual Subst</a>, which provides a nice interface to the same functionality.</p>
<p>With this, you can tell Lightroom that all your photos are under P:\.  Create a P: drive that points to where you have your photos stored.  Then, open Lightroom, and under Folders on the left side, right click on each folder and select &#8220;Update Folder Location&#8221;.  Navigate to the same folder under P:\, and select OK.</p>
<p>Now, copy all your photo folders to a portable drive.  Take that drive to another computer, plug it in, use <em>subst</em> to set up your P:\ drive, and open Lightroom &#8212; it should see your photos, oblivious to the fact that it&#8217;s on a different computer and getting the photos from a portable drive!</p>
<p>You can change the P:\ mapping at will.  For example, I keep my photos sorted by date, with the top level folder being the year.  My laptop only has the contents of the 2010 folder.  Any earlier ones are backed up on the drive (and in other places).  In Lightroom, these other folders show up grayed out with a little ? next to them.  If I need to do something with these, I plug in the external drive, change where P: points to, restart Lightroom, and I&#8217;m back in business.</p>
<h3>Actually synchronizing your photo collection</h3>
<p>Now that you have the import and edit photos using the same catalog anywhere, you need a good solution for actually keeping the photo folder contents up to date, and making sure new changes make it to your various backups.</p>
<p>Unfortunately, I don&#8217;t have good instructions for this, especially on Windows.  On a Mac, you can use <em>rsync</em>, and there&#8217;s likely a nice UI for it somewhere  On Windows, you&#8217;d want to use <em>rsync</em> as well, but I&#8217;ve yet to find a version of rsync that seems to work well.  Unison is also an option, but I&#8217;ve had problems with it as well.  Right now I do a somewhat manual job of keeping these photos up to date.  Usually it&#8217;s not difficult, because I just add photos (so it involves copying a few new by-date folders over), but it gets complicated if I do any edits in Photoshop.</p>
<p>If I come up with a good solution here, I&#8217;ll update this post in the future.</p>
<h3>Wrap-up</h3>
<p>That&#8217;s it!  Enjoy having your Lightroom catalog available everywhere and not being tied to one computer for editing your photos.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/11/20/using-adobe-lightroom-with-dropbox/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Building Fennec for Android under Win32</title>
		<link>http://blog.vlad1.com/2010/11/01/building-fennec-for-android-under-win32/</link>
		<comments>http://blog.vlad1.com/2010/11/01/building-fennec-for-android-under-win32/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 21:50:33 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[fennec]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=348</guid>
		<description><![CDATA[I&#8217;ve been using Windows 7 as my primary development platform for a while (don&#8217;t let the MacBook Pro fool you &#8212; it&#8217;s probably spent less than an hour total in MacOS X), but have always needed to use a virtual machine running Linux to make Android builds.  I don&#8217;t mind working in a VM, but [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Windows 7 as my primary development platform for a while (don&#8217;t let the MacBook Pro fool you &#8212; it&#8217;s probably spent less than an hour total in MacOS X), but have always needed to use a virtual machine running Linux to make Android builds.  I don&#8217;t mind working in a VM, but it takes up a large chunk of memory, and makes it hard to share code/patches with my main source trees.</p>
<p>However, Google provides the cross-compilers for Windows as well; since the external drive that had my VM on it died a week ago, it seemed like a good opportunity to get the build working under Windows.  Because the native compilers are built using cygwin, this is a bit convoluted, but seems to work.  You&#8217;ll need some msys and cygwin tools, as well as the standard Android build prereqs (Java, SDK, NDK):</p>
<ul>
<li>mozilla-build installed</li>
<li>the <a href="http://ftp.mozilla.org/pub/mozilla.org/mozilla/source/wintools.zip">mingw moztools</a>, unpacked somewhere like c:\mozilla-build\moztools-mingw (see bug comment as to why this is required)</li>
<li>cygwin installed, including gcc/g++ and the mingw 4.5.1 compilers</li>
<li>a <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JDK</a> (note: I don&#8217;t know if OpenJDK supports Windows; if it does, that&#8217;s also an option)</li>
<li>the <a href="http://developer.android.com/sdk/index.html">Android SDK</a> (with at least the platform level 8 SDK)</li>
<li>the <a href="http://www.crystax.net/android/ndk-r4.php">Crystax r4 NDK</a> for Win32</li>
<li>the patches from <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=607975">bug 607975</a></li>
</ul>
<p>You do the build inside the standard mozilla-build shell prompt (<em>not</em> a cygwin shell).  However, you&#8217;ll need to copy *.dll from c:/cygwin/bin (assuming you installed cygwin in c:/cygwin) into a new directory, such as c:/cygwin/bindll.  Then add that bindll directory to your msys path.  Adding the cygwin bin directory to your msys path will get you cygwin versions of various tools, and will greatly confuse things.  You just need the DLLs so that the compilers can execute; the compiler binary paths are explicitly specified.</p>
<p>There&#8217;s a sample mozconfig inside bug 607975.  You&#8217;ll need to use a relative path to run configure, e.g. &#8220;MOZCONFIG=../../fennec-config ../mozilla-central/configure&#8221;, and you must use mingw make and not pymake to build.  pymake has some weird issues, where it complains that it doesn&#8217;t know how to rebuild dependencies like &#8220;-lzlib&#8221;.  This is likely fixable, because I think this is a magic thing that gnu make special-cases, and something that our build system shouldn&#8217;t do in any case.</p>
<p>Some remaining problems with the build:</p>
<ul>
<li>It&#8217;s not clear why jemalloc hangs without the TLS patch; mwu says he has seen this in other cases, but it&#8217;s consistent here.</li>
<li>Opt builds seem to just draw white; not sure why that is, debug builds work fine.  This should be fixable.</li>
<li>Disabling automatic dependencies means you have to be extra careful if you modify a header file or something that might not get picked up; they have to be disabled because the cygwin compiler will generate paths like &#8220;/cygwin/c/&#8230;&#8221; in the deps file, which the msys make won&#8217;t ever be able to find &#8212; thus causing it to rebuild everything on every build.  This is also fixable, perhaps with a postprocessing step after each compilation.</li>
<li>Would be nice if pymake worked for building speed.</li>
</ul>
<p>This is obviously not a full solution, and VMs are still a lot more stable where builds are concerned, but it&#8217;s at least possible to build Fennec for Android under Win32.  GDB also seems to work fine, though as always, you&#8217;ll want to use the <a href="https://wiki.mozilla.org/Mobile/Fennec/Android#Using_nVidia_version_.28recommended.29">NVIDIA-provided gdb/gdbserver</a> pair, because the one that&#8217;s part of the NDK seems to continue to have issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/11/01/building-fennec-for-android-under-win32/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Information from Windows Vista/7 Display Driver Resets</title>
		<link>http://blog.vlad1.com/2010/10/12/getting-information-from-windows-vista7-display-driver-resets/</link>
		<comments>http://blog.vlad1.com/2010/10/12/getting-information-from-windows-vista7-display-driver-resets/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 16:41:03 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[crashes]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=339</guid>
		<description><![CDATA[Now that we&#8217;re doing hardware acceleration on all platforms, we&#8217;re touching all sorts of OS components that we haven&#8217;t in the past.  One of those is much closer interaction with the graphics card drivers in your system.  Under Windows Vista and Windows 7, problems in the video driver (or in how we use DirectX/OpenGL) sometimes [...]]]></description>
			<content:encoded><![CDATA[<p>Now that we&#8217;re doing hardware acceleration on all platforms, we&#8217;re touching all sorts of OS components that we haven&#8217;t in the past.  One of those is much closer interaction with the graphics card drivers in your system.  Under Windows Vista and Windows 7, problems in the video driver (or in how we use DirectX/OpenGL) sometimes manifest themselves as a graphics driver rest: your screen flashes, and you have a little popup telling you that your video driver had a problem and was reset. If this happens to you while using one of the Firefox 4 betas or nightly builds, here&#8217;s how you can collect information to help us and the graphics hardware vendor fix the problem.  This only applies to Windows Vista and Windows 7.</p>
<h3>1. Did Firefox recover?</h3>
<p>Immediately after the driver reset, did Firefox recover?  If so, skip this step.  If, however, it&#8217;s not repainting and otherwise seems hung, forcing a crash report can help give us data that we need to figure out why recovery didn&#8217;t happen properly.  To do this, I wrote a tool that forces a hung Firefox to crash in a way that will pop up the crash reporter.  You can download it here: <a href="http://people.mozilla.com/~vladimir/misc/force-firefox-crash.zip">force-firefox-crash.zip</a>.  Just unzip and double click on the .exe, and the current running firefox.exe process will be killed, and you&#8217;ll be presented with the crash reporter.</p>
<p>Submit the report, and after restarting Firefox, type in <strong>about:crashes</strong> in the location bar.  You&#8217;ll want the ID of the top entry in this list for when you file a bug or contact support later.  (You can right click the top link and select &#8220;Copy Link Location&#8221; to grab a link for easy pasting.)</p>
<h3>2. Grab the Driver Crash information</h3>
<p>Select the start menu, and type in &#8220;problem report&#8221; in the search box.  Select <strong>View all problem reports </strong>from the list:</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-view-problem-reports.jpg"><img class="size-full wp-image-341  aligncenter" title="View all problem reports" src="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-view-problem-reports.jpg" alt="" width="409" height="321" /></a></p>
<p>In the problem reports list, scroll down to the Windows section if it&#8217;s not visible, and sort by Date &#8212; you want the latest &#8220;Video hardware error&#8221; entry:</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-2.png"><img class="size-full wp-image-342  aligncenter" title="Video hardware error" src="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-2.png" alt="" width="400" height="273" /></a></p>
<p>Double-click on the latest &#8220;Video hardware error&#8221; entry.  In the details screen, click &#8220;View a temporary copy of these files&#8221;:</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-3.png"><img class="size-full wp-image-343  aligncenter" title="Temporary Copy" src="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-3.png" alt="" width="400" height="320" /></a></p>
<p>You&#8217;ll get a new explorer window with three files.  Select all three, and compress them into a ZIP file, by right-clicking and selecting &#8220;Send To -&gt; Compressed Folder&#8221;:</p>
<p style="text-align: center;"><a href="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-4.jpg"><img class="size-full wp-image-344  aligncenter" title="wer-4" src="http://blog.vlad1.com/wp-content/uploads/2010/10/wer-4.jpg" alt="" width="400" height="261" /></a></p>
<p>Copy the resulting zip file to your desktop, so that you can include it with your report.</p>
<h3>3. Create a bug</h3>
<p>Almost done! In <a href="http://bugzilla.mozilla.org">bugzilla.mozilla.org</a>, create a new bug in the Core product and the Graphics component.  Attach the zip file you created in step two to the report.  If you also created a Firefox crash dump in step one, include a link to it in your bug report.</p>
<p>This should give us and the graphics hardware vendors enough information to track down what the original problem was, so that we can fix it for Firefox 4!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/10/12/getting-information-from-windows-vista7-display-driver-resets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fun With Fast JavaScript</title>
		<link>http://blog.vlad1.com/2010/07/30/fun-with-fast-javascript/</link>
		<comments>http://blog.vlad1.com/2010/07/30/fun-with-fast-javascript/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 21:14:18 +0000</pubDate>
		<dc:creator>vladimir</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[perf]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.vlad1.com/?p=315</guid>
		<description><![CDATA[Fast JavaScript is a cornerstone of the modern web. In the past, application authors had to wait for browser developers to implement any complex functionality in the browser itself, so that they could access it from script code. Today, many of those functions can move straight into JavaScript itself. This has many advantages for application [...]]]></description>
			<content:encoded><![CDATA[<p>Fast JavaScript is a cornerstone of the modern web.  In the past, application authors had to wait for browser developers to implement any complex functionality in the browser itself, so that they could access it from script code.  Today, many of those functions can move straight into JavaScript itself.  This has many advantages for application authors: there&#8217;s no need to wait for a new version of a browser before you can develop or ship your app, you can tailor the functionality to exactly what you need, and you can improve it directly (make it faster, higher quality, more precise, etc.).</p>
<p><a href="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1353.png"><img class="alignleft size-full wp-image-316" title="JavaScript Darkroom" src="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1353.png" alt="" width="300" height="238" /></a>Here are two examples that show off what can be done with the improved JS engine and capabilities that will be present in Firefox 4.  The first example shows <a href="http://people.mozilla.com/~vladimir/demos/darkroom/darkroom.html">a simple web-based Darkroom</a> that allows you to perform color correction on an image.  The HTML+JS is around 700 lines of code, not counting jQuery.  This is based on a demo that&#8217;s included with Google&#8217;s Native Client (NaCl) SDK; in that demo, the color correction work is done inside native code going through NaCl.  That demo (originally presented as &#8220;too slow to run in JavaScript&#8221;) is a few thousand lines of code, and involves downloading and installing platform-specific compilers, multiple steps to test/deploy code, and installing a plugin on the browser side.</p>
<p>I get about 15-16 frames per second with the default zoomed out image (around 5 million pixels per second &#8212; that number won&#8217;t be affected by image size) on my MacBook Pro, which is definitely fast enough for live manipulation.  The algorithm could be tightened up to make this faster still.  Further optimizations to the JS engine could help here as well; for example, I noticed that we spend a lot of time doing floating point to integer conversions for writing the computed pixels back to the display canvas, due to how the canvas API specifies image data handling.</p>
<p>The Web Darkroom tool also supports drag &amp; drop, so you can take any image from your computer and drop it onto the canvas to load it.  A long (long!) time ago, back in 2006, I wrote <a href="http://people.mozilla.com/~vladimir/corppr/">an addon called &#8220;Croppr!&#8221;</a>.  It was intended to be used with Flickr, allowing users to play around with custom crops of any image, and then leave crop suggestions in comments to be viewed using Croppr.  It almost certainly doesn&#8217;t work any more, but it would be neat to update it: this time with both cropping and color correction.  Someone with the addon (perhaps a <a href="https://jetpack.mozillalabs.com/">Jetpack</a> now!) could then visit a Flickr photo and experiment, and leave suggestions for the photographer.</p>
<p><a href="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1352.png"><img class="alignright size-full wp-image-318" title="JavaScript Video FFT" src="http://blog.vlad1.com/wp-content/uploads/2010/07/2010-06-24_1352.png" alt="" width="350" height="425" /></a>The <a href="http://people.mozilla.com/~vladimir/demos/jsfft/jsfft.html">second example</a> is based on some work that Dave Humphrey and others have been doing to bring audio manipulation to the web platform.  Originally, their spec included a pre-computed FFT with each audio frame delivered to the web app.  I suggested that there&#8217;s no need for this &#8212; while a FFT is useful for some applications, for others it would be wasted work.  Those apps that want a FFT could implement one in JS.  Some benchmark numbers backed this up &#8212; using the <a href="https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html">typed arrays</a> originally created for <a href="http://webgl.org/">WebGL</a>, computing an FFT in JS was approaching the speed of native code.  Again, both could be sped up (perhaps using SSE2 or something like Mono.Simd on the JS side), but it&#8217;s fast enough to be useful already.</p>
<p>The demo shows this in action.  A numeric benchmark isn&#8217;t really all that interesting, so instead I take a video clip, and as it&#8217;s playing, I extract a portion of the green channel of each frame and compute its 2D FFT, which is then displayed.  The original clip plays at 24 frames per second, so that&#8217;s the upper bound of this demo.  Using Float32 typed arrays, the computation and playback proceeds at around 22-24fps for me.</p>
<p>You can grab the video controls and scrub to a specific frame.  (The frame rate calculation is only correct while the video is playing normally, not while you&#8217;re scrubbing.)  The video source uses Theora, so you&#8217;ll need a browser that can play Theora content.  (I didn&#8217;t have a similar clip that uses WebM, or I could have used that.)</p>
<p>These examples are demonstrating the strength of the trace-based JIT technique that Firefox has used for accelerating JavaScript since Firefox 3.5.  However, not all code can see such dramatic speedups from that type of acceleration.  Because of that, we&#8217;ll be including a full method-based JIT for Firefox 4 (for more details, see <a href="http://www.bailopan.net/blog/?p=683">David Anderson&#8217;s blog</a>, as well as <a href="http://blog.mozilla.com/dmandelin/2010/05/10/jm-halfway/">David Mandelin&#8217;s blog</a>).  This will provide significantly faster baseline JS performance, with the trace JIT becoming a turbocharger for code that it would naturally apply to.</p>
<p>Combining fast JavaScript performance alongside new web platform technologies such as WebGL and Audio will make for some pretty exciting web apps, and I&#8217;m looking forward to seeing what developers do with them!</p>
<p><em>Edit: Made some last-minute changes to the demos, which ended up pulling in a slightly broken version of jQuery UI that wasn&#8217;t all that happy with Safari.  Should be fixed now!</em></p>
<p><em>Edit #2: This <a href="http://www.movavi.com/opensource/fun-with-fast-javascript-be">post is available in Belorussian</a>, courtesy of Jason Fragoso!</em><a href="http://www.movavi.com/opensource/fun-with-fast-javascript-be" target="_blank"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vlad1.com/2010/07/30/fun-with-fast-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>1</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>
	</channel>
</rss>

