The "Compiling Javascript" loader takes way too long (at least on my system) to not give any indication as to how long I will wait or whether it's still doing anything. At least a "this might take up to X minutes".
Demo itself ran halfway ok, clicking on 'Benchmark' (which I had to guess was in the upper pulldown) immediately froze everything for me (Firefox on Kubuntu).
Still: I do appreciate a demo that even kinda-sorta works on gnu/linux.
I've found it works almost flawlessly on ArchLinux 64bit with the standard Firefox package. Only one minor issue with the flag in the wind going all over the place, but that's probably the fault of open source radeon driver.
It is very refreshing to see something cutting edge work on linux.
I love the fact that Mozilla keeps pushing javascript to its limits. They seem to be doing a lot of things really well lately, this is awesome!! Plus you have Firefox OS, which pushes web-standards to native mobile. Now I just wish the devtools would get up to paar with those on chrome/chromium and I'd be switching back to FF in a heartbeat.
I wish google would stay on board with JS since they have the engineering power to do a lot in this area, but to me it seems after V8 they've kind of abbonned JS in favor of Dart (As oppossed to supporting asm.js). For instance, I just did the "try anyway" in chrome 26.0 linux and everything crashed. Did anyone get it working in chrome?
You would think, but I've noticed that on HN specifically, the comment pointing out that a stupid argument is forming--if it gets in early enough--tends to be both highly upvoted, and the end of the argument. One reason I like this community.
And yours is very polite and contribute a lot to the discussion ;-)
but being the devils advocate here, both parents of your comment are not that far off.
Ubuntu is more prone to crash because it invites the user to install much more closed source and proprietary code, by design. so they are not that idiotic and flamebaitic.
My bet: the OS and all the code running on it is written correctly. and you can see it gave you a warning about tainted kernel when you loaded that piece of crap nvidia/ati proprietary driver.
I've never once had an application in Linux crash the whole OS - or at least not so long as I've had physical access to the machine (I've had rouge database requests brick a server before because it took down sshd - but that's a different story)
In fact on the laptop I'm on now, the parent link crashed Firefox. But it OOM'ed and got killed before I even noticed there was a problem (and that's on a beefy desktop environment with compositing enabled too)
I've had problems with fglrx where it crashes because you resize the window too quickly, and then it's done something really funky, so when you do CTRL+ALT+F_N it doesn't actually give you a shell.
Chromium has been a little dodgy for me lately too. Lots of memory leaks and what not. I've had to kill it's parent process id on a number of occasions (but even then, there's no reason why a browser should take out the whole OS).
Basically, each font in each size uses some handles in a renderer. At 10000 handles, the tab renderer dies. They have a font cache but never clear it.
When enough render processes together use too many GDI handles, the whole Windows desktop breaks down.
The only amazing stuff is the distribution mechanism really. Other stuff is just plain old OpenGL but in your browser this time. It is not like it has some crazy support for raytraced voxels or something.
I personally love that OpenGL is 'plain old' haha. Not to criticise your comment at all - but as someone who's been forced to work with OpenGL 3.3-4 quite a lot recently ... it's pretty incredible at times.
Also - as I understand it, what's impressive about all this isn't just the graphics. Once you've passed vertices etc... off to the graphics pipeline then yes Javascript doesn't handle much of the load .... but as we know a lot of games are CPU bound, and the fact that Javascript is increasingly able to offer acceptable performance relative to the native compiled experience of c/c++ is pretty nuts.
> The only amazing stuff is the distribution mechanism really.
That's the main thing, but not the only thing.
WebGL is also very portable, more than other flavors of GL. Huge effort has gone into that. As a result there is a much better chance a WebGL app will give the same output on different browsers/OSes/GPUs (and if it does not, that's a bug that should be fixed).
WebGL is also more secure than OpenGL, since it was designed to run in a web browser, that executes unsafe code off the web.
The original team working on V8 in Aarhus switched to work on Dart, so V8 transferred ownership to a team in Munich. It is still very much alive and well :)
Apparently, they are still trying to make V8 faster. V8's graph isn't flat and there are also very recent bumps.
>As oppossed to supporting asm.js
Asm.js is about JavaScript the compiler target, not JavaScript itself. Using asm.js means writing code in C/C++ (or something similar), which means it's more comparable to PNaCl than Dart.
This is awesome! I wished I could run cause its slow to walk around but then I discovered you can alt-tab to another window and keep the event for W active
As someone who grew up in a time where you had to tweak your config.sys and autoexec.bat files so that you could get a few extra FPS on Duke Nukem 3D, I can tell you: this is pretty freaking amazing.
As the demo says, it's recommended to try it in Firefox Nightly. The demo starts up and runs much faster there thanks to optimizations that are not yet in the stable release (which is what you're running, I think).
>One concern for this type of product is that there's no concept of "installing" a webapp. The website will need to stream all game resources to the client for each user. I would wager that's one reason the graphics are poor: all of what you see was probably generated from <100MB of content.
It doesn't work for me. I downloaded Nightly using the provided link, but when I open the URL it still says unsupported browser. It also doesn't have the option to 'try anyway' like Chrome does.
Definitely awesome, still a while before this is usable in the market (across many browsers) and load times seem longer than Unity/Flash. I can't wait until browser support of emscripten/asm.js is better.
This ran surprisingly well on my 3+ year old Asus laptop with integrated graphics. By surprisingly well, I mean I doubt I ever got over 30 fps (probably 15 fps on average) but there were little to no hitches when loading new areas.
I wouldn't be able to play a fast paced shooter like this, but I could see it being more than tolerable for playing a slow paced role playing game or something in the browser, with the added ease of connecting with other players, possibly MMORPG-style.
On a side note, it'd be nice to make it capture the mouse instead of having to drag it.
Controlling the spectator is remarkably bad. I hope this is not how i am supposed to play video games. Even Dead Space 1 is better, and that was so bad i could not stand it for more than 30 minutes.
Well, unusually, this demo isn't using the Pointer Lock API to do normal FPS-style controls. It's fully possible to do them, but this demo doesn't for some reason.
The question I always ask when I see this is: Why?
Why do you put serious effort into a technology which is perfomance wise years behind. Why do we take steps back, just because "it's in the browser" => "now it's cool".
Ran this on a laptop on Firefox 20 (stable) with Bumblebee and it's surprisingly impressive and smooth.
I have a gaming desktop at home that runs all new games at 50+ FPS, but for some reason looking at graphics that a late-era PS2/early PS3 game would have _in a browser_ is more impressive than running a game like Crysis 3 for the first time.
Even though it's using JavaScript as a kind of bytecode, it is just JavaScript / HTML5 (and some CSS, but that's pretty anedoctical I guess). Asm.js is a subset of JavaScript. As soon as Chrome fixes the crash, it'll run in a browser that supports just HTML5 (for presenting the page / the DOM / the canvas) and JavaScript with no special asm.js optimizations, and we'll have to see how fast/slow it is then.
To correct your analogy: it'd be like using a subset of C# as the bytecode rather than a language. It's still actual C#, it's not just .NET bytecode, but it's being used differently.
I have a lot of respect for Egorov, and I agree with his views on this matter quite entirely.
The sole benefit of embedding a bytecode in a language is that you get the side effect that it can run anywhere that language runs. But in general, this implies performance penalties, especially when the language is relatively slow to begin with.
But in this case, this demo is made usable (ie: the impressive part) by writing a compiler specifically for the bytecode itself. So it works well in spite of the fact that it's a bytecode embedded in JS, not because of it. The really cool things about this demo are precisely 2 things:
1. asm.js makes running C++ code that would render to OpenGL in the browser a possibility, and with relatively good performance. Kudos to Mozilla.
2. It runs on browsers that don't know about asm.js, but it's effectively an emulated machine, and it's slow.
I just take issue with calling this an example of what JavaScript/HTML5 can do. I think seeing an application written in JS using WebGL or Canvas as something much more impressive, and there are Q3 renderers that are natively JS that run with amazing performance in the browser. This is just dressing up the fact that turing completeness is a thing and calling attention to it. The real thing to get from this demo is that there are enormous benefits to having a bytecode for the web over trying to optimize a fully dynamic language like JS. I feel like that is relatively lost by the title.
> 1. asm.js makes running C++ code that would render to OpenGL in the browser a possibility, and with relatively good performance. Kudos to Mozilla.
> 2. It runs on browsers that don't know about asm.js, but it's effectively an emulated machine, and it's slow.
Do you have benchmark numbers to support that? In my experience, asm.js code is quite fast even without special asm.js optimizations. It depends on the benchmark obviously, but look at
Many of those benchmarks are very fast in browsers without special asm.js optimizations.
All they need to do to be fast on asm.js code is to optimize typed array operations and basic math, and those are things browsers have been doing for a long time. Google even added a Mandreel benchmark to Octane for this reason.
Emscripten and Mandreel output, with or without asm.js, tends to be quite fast, generally faster than handwritten code. asm.js is often faster than that, because it's easier to optimize, even without special optimizations for it. Those special optimizations can help even more, but they are not necessary for it to run, nor are things "slow/emulated" without them.
That link is misleading in the context you present it. Those are microbenchmarks, which a JIT can optimize relatively well. But if you look at the very next slide at http://kripken.github.io/mloc_emscripten_talk/#/28 you will see that for a larger application, non-optimized asm.js performs abysmally, as does JS in general. A performance penalty of ~1000% of native is what you should expect for a nontrivial JS application, and asm.js does not do much (if anything) to alleviate that unless you run odinmonkey.
I was purposefully linking to that slide + the one after it.
Yes, there is a factor of around 4x slowdown between asm.js optimizations and without them, on the next slide. But even 4x slower than asm.js is quite fast, it's enough to run the Epic Citadel demo for example (try it on a version of firefox without those optimizations, like stable release - as others reported in comments, it runs ok). A lot of the work in Epic Citadel is on the GPU anyhow, say it's about half, so the difference is then only something like 2x.
2x is not that much, we have similar differences on the web anyhow because of CPU differences, JIT differences, etc. That's within the expected range of variance.
It's faster than "handwritten JS" because it's using a subset of JS that's already tuned to near the peak level of performance that you can achieve in JITting JS, which is tightly looped arithmetic with everything inlined working on SMIs. In V8, that's ~2.5x slower than the equivalent C code with optimizations. That's basically best case.
The problem is that it's still dynamic, and at any point a null can come along and force you to throw away a JITted function, so you have to have these checks everywhere just in case. Further, ECMA compliance does not require JIT compilation, which means to expect performance, especially on the web, is dubious at best. I can see merit to expecting performance metrics in something like Node.JS since it assumes V8, but the web does not have 1 JS engine, and the standard does not require such performance metrics.
The "benefits" of building a bytecode in that's represented in some subset of JS are essentially red herrings since they're effectively lies and the downsides are a lot more significant, IMO. Instead, we should be focusing on actually building a bytecode for the web such that all implementations are expected to have certain performance metrics.
I'm on a pretty old laptop and this runs extremely well on Windows 7 (using Nightly). I also tried it on Xubuntu 13.04, but I couldn't get it to run (I tried it on Chromium and Firefox).
So it basically means that C++ got another reasonable compilation target. Not much to do with applying JavaScript to large-scale games. Also it is not HTML 5, it is HTML FF23.
Factually, all code emitted from emscripten is JavaScript. It may look funny with all the bitwise operators that are barely ever used by web developers, but it's just JavaScript. It doesn't run correctly in Chrome right now because they have issues with their JavaScript environment not supporting large numbers of variables for a given context. It doesn't run in IE because IE doesn't support webGL. Both of these will be fixed in the future.
> I take issue with calling this JavaScript/HTML5. This is powered by asm.js.
It is faster with asm.js optimizations, but as other comments mention, it also runs well (depending on CPU/GPU) even without such optimizations, in browsers that have no special asm.js optimizations whatsoever.
All the demo needs to work is WebGL and JavaScript.
> The source is emphatically NOT JavaScript, it's a subset that's meant to be a target for compilation
It is not 'typical' JavaScript, but it literally is JavaScript since it's a subset.
> (like a bytecode in .NET and the JVM) and is treated entirely differently from JavaScript by the JIT.
Only in some cases (Firefox 22 and 23) is it treated in a special way, and as mentioned above, the demo works great in other cases as well, that treat it like normal JavaScript (Firefox 20 stable, for example).
Even when it is treated in a special way, it still uses the same parser and same backend and optimizations (IonMonkey) as the Firefox JS engine uses for all JS.
> We don't call everything that runs on .NET C# nor everything that runs on the JVM Java.
The main difference is that .NET and the JVM have bytecodes. C# is not .NET bytecode and Java is not JVM bytecode. But, JavaScript does not have a universal bytecode, there is just the language itself.
So asm.js is literally JavaScript, not some lower-level bytecode. It runs like normal JavaScript, the only difference is that some JS engines might optimize it a little better, since it's easy to optimize.
Note that asm.js-like code is nothing new. It's been generated for years now by compilers like Emscripten and Mandreel, and Firefox and Chrome (and likely others) have been optimizing for it, for example Google added a Mandreel benchmark to Octane. (The only thing new with asm.js is that there is a formal typesystem which makes it simple to make sure you emit proper code, and simple to verify you are receiving proper code; also, while developing the type system some bugs in how emscripten generates code were found and resolved.)
"It is faster with asm.js optimizations, but as other comments mention, it also runs well (depending on CPU/GPU) even without such optimizations, in browsers that have no special asm.js optimizations whatsoever."
Actually, that's not true at all. That's the plan for asm.js, but this demo doesn't run in anything other than very new Firefox builds, AFAICT. It crashes chrome, IE doesn't support WebGL (yet).
157 comments
[ 3.9 ms ] story [ 209 ms ] threadDemo itself ran halfway ok, clicking on 'Benchmark' (which I had to guess was in the upper pulldown) immediately froze everything for me (Firefox on Kubuntu).
Still: I do appreciate a demo that even kinda-sorta works on gnu/linux.
It is very refreshing to see something cutting edge work on linux.
It is actually both downloading and compiling during that time, and probably spending far more time in the download.
It would be nicer if the text said "retrieving code" as opposed to "compiling code" at that point.
edit: looks like the demo site was just updated, the message is better now :)
I'm using Firefox 20 on Ubuntu 12.04/amd64 and everything works flawlessly.
I wish google would stay on board with JS since they have the engineering power to do a lot in this area, but to me it seems after V8 they've kind of abbonned JS in favor of Dart (As oppossed to supporting asm.js). For instance, I just did the "try anyway" in chrome 26.0 linux and everything crashed. Did anyone get it working in chrome?
Crashed my whole system
Chromium 25.0.1364.160 Ubuntu 12.04
but being the devils advocate here, both parents of your comment are not that far off.
Ubuntu is more prone to crash because it invites the user to install much more closed source and proprietary code, by design. so they are not that idiotic and flamebaitic.
I've never once had an application in Linux crash the whole OS - or at least not so long as I've had physical access to the machine (I've had rouge database requests brick a server before because it took down sshd - but that's a different story)
In fact on the laptop I'm on now, the parent link crashed Firefox. But it OOM'ed and got killed before I even noticed there was a problem (and that's on a beefy desktop environment with compositing enabled too)
Basically, each font in each size uses some handles in a renderer. At 10000 handles, the tab renderer dies. They have a font cache but never clear it. When enough render processes together use too many GDI handles, the whole Windows desktop breaks down.
Hardest crash I've experienced on this new setup.
Also - as I understand it, what's impressive about all this isn't just the graphics. Once you've passed vertices etc... off to the graphics pipeline then yes Javascript doesn't handle much of the load .... but as we know a lot of games are CPU bound, and the fact that Javascript is increasingly able to offer acceptable performance relative to the native compiled experience of c/c++ is pretty nuts.
That's the main thing, but not the only thing.
WebGL is also very portable, more than other flavors of GL. Huge effort has gone into that. As a result there is a much better chance a WebGL app will give the same output on different browsers/OSes/GPUs (and if it does not, that's a bug that should be fixed).
WebGL is also more secure than OpenGL, since it was designed to run in a web browser, that executes unsafe code off the web.
You make it sound like they're the only ones doing this kind of thing. Anybody remember this?
www.findyourwaytooz.com
Where did you get that idea? Just look at these graphs:
http://www.dartlang.org/performance/
Apparently, they are still trying to make V8 faster. V8's graph isn't flat and there are also very recent bumps.
>As oppossed to supporting asm.js
Asm.js is about JavaScript the compiler target, not JavaScript itself. Using asm.js means writing code in C/C++ (or something similar), which means it's more comparable to PNaCl than Dart.
It is still just javascript and totally readable as such.
For example: https://gist.github.com/calvinmetcalf/5473022
Haven't they announced that they have no plans to integrate the Dart VM with the Blink rendering engine?
edit: although there is no path finding
The main difference are the optimizations currently on Firefox Nightly. They'll be in a stable release in just a few months or less.
Need to stream it to the user once.
And running a site on a given domain isn't hard.
What?
Unless you're streaming one single massive multi-gigabyte blob, instead of different asset packs, there's no reason they wouldn't be possible.
I wouldn't be able to play a fast paced shooter like this, but I could see it being more than tolerable for playing a slow paced role playing game or something in the browser, with the added ease of connecting with other players, possibly MMORPG-style.
On a side note, it'd be nice to make it capture the mouse instead of having to drag it.
http://www.unrealengine.com/flash/
Is anybody able to get it running on android? The nightly has both asm and webgl but is showing up as unsupported (and not just doing UA sniffing).
https://twitter.com/vvuk/status/330119715546624000
I have a gaming desktop at home that runs all new games at 50+ FPS, but for some reason looking at graphics that a late-era PS2/early PS3 game would have _in a browser_ is more impressive than running a game like Crysis 3 for the first time.
To correct your analogy: it'd be like using a subset of C# as the bytecode rather than a language. It's still actual C#, it's not just .NET bytecode, but it's being used differently.
I have a lot of respect for Egorov, and I agree with his views on this matter quite entirely.
The sole benefit of embedding a bytecode in a language is that you get the side effect that it can run anywhere that language runs. But in general, this implies performance penalties, especially when the language is relatively slow to begin with.
But in this case, this demo is made usable (ie: the impressive part) by writing a compiler specifically for the bytecode itself. So it works well in spite of the fact that it's a bytecode embedded in JS, not because of it. The really cool things about this demo are precisely 2 things:
1. asm.js makes running C++ code that would render to OpenGL in the browser a possibility, and with relatively good performance. Kudos to Mozilla.
2. It runs on browsers that don't know about asm.js, but it's effectively an emulated machine, and it's slow.
I just take issue with calling this an example of what JavaScript/HTML5 can do. I think seeing an application written in JS using WebGL or Canvas as something much more impressive, and there are Q3 renderers that are natively JS that run with amazing performance in the browser. This is just dressing up the fact that turing completeness is a thing and calling attention to it. The real thing to get from this demo is that there are enormous benefits to having a bytecode for the web over trying to optimize a fully dynamic language like JS. I feel like that is relatively lost by the title.
> 2. It runs on browsers that don't know about asm.js, but it's effectively an emulated machine, and it's slow.
Do you have benchmark numbers to support that? In my experience, asm.js code is quite fast even without special asm.js optimizations. It depends on the benchmark obviously, but look at
http://kripken.github.io/mloc_emscripten_talk/#/27
Many of those benchmarks are very fast in browsers without special asm.js optimizations.
All they need to do to be fast on asm.js code is to optimize typed array operations and basic math, and those are things browsers have been doing for a long time. Google even added a Mandreel benchmark to Octane for this reason.
Emscripten and Mandreel output, with or without asm.js, tends to be quite fast, generally faster than handwritten code. asm.js is often faster than that, because it's easier to optimize, even without special optimizations for it. Those special optimizations can help even more, but they are not necessary for it to run, nor are things "slow/emulated" without them.
Yes, there is a factor of around 4x slowdown between asm.js optimizations and without them, on the next slide. But even 4x slower than asm.js is quite fast, it's enough to run the Epic Citadel demo for example (try it on a version of firefox without those optimizations, like stable release - as others reported in comments, it runs ok). A lot of the work in Epic Citadel is on the GPU anyhow, say it's about half, so the difference is then only something like 2x.
2x is not that much, we have similar differences on the web anyhow because of CPU differences, JIT differences, etc. That's within the expected range of variance.
Also, asm.js code is faster even without special optimizations compared to handwritten JS (see for example http://blog.j15r.com/blog/2011/12/15/Box2D_as_a_Measure_of_R... and http://blog.j15r.com/blog/2013/04/25/Box2d_Revisited ). So even without those optimizations it is worthwhile.
The problem is that it's still dynamic, and at any point a null can come along and force you to throw away a JITted function, so you have to have these checks everywhere just in case. Further, ECMA compliance does not require JIT compilation, which means to expect performance, especially on the web, is dubious at best. I can see merit to expecting performance metrics in something like Node.JS since it assumes V8, but the web does not have 1 JS engine, and the standard does not require such performance metrics.
The "benefits" of building a bytecode in that's represented in some subset of JS are essentially red herrings since they're effectively lies and the downsides are a lot more significant, IMO. Instead, we should be focusing on actually building a bytecode for the web such that all implementations are expected to have certain performance metrics.
As for the demo, I'm stunned. It's incredible.
Still, it's pretty amazing.
It is faster with asm.js optimizations, but as other comments mention, it also runs well (depending on CPU/GPU) even without such optimizations, in browsers that have no special asm.js optimizations whatsoever.
All the demo needs to work is WebGL and JavaScript.
> The source is emphatically NOT JavaScript, it's a subset that's meant to be a target for compilation
It is not 'typical' JavaScript, but it literally is JavaScript since it's a subset.
> (like a bytecode in .NET and the JVM) and is treated entirely differently from JavaScript by the JIT.
Only in some cases (Firefox 22 and 23) is it treated in a special way, and as mentioned above, the demo works great in other cases as well, that treat it like normal JavaScript (Firefox 20 stable, for example).
Even when it is treated in a special way, it still uses the same parser and same backend and optimizations (IonMonkey) as the Firefox JS engine uses for all JS.
> We don't call everything that runs on .NET C# nor everything that runs on the JVM Java.
The main difference is that .NET and the JVM have bytecodes. C# is not .NET bytecode and Java is not JVM bytecode. But, JavaScript does not have a universal bytecode, there is just the language itself.
So asm.js is literally JavaScript, not some lower-level bytecode. It runs like normal JavaScript, the only difference is that some JS engines might optimize it a little better, since it's easy to optimize.
Note that asm.js-like code is nothing new. It's been generated for years now by compilers like Emscripten and Mandreel, and Firefox and Chrome (and likely others) have been optimizing for it, for example Google added a Mandreel benchmark to Octane. (The only thing new with asm.js is that there is a formal typesystem which makes it simple to make sure you emit proper code, and simple to verify you are receiving proper code; also, while developing the type system some bugs in how emscripten generates code were found and resolved.)
Actually, that's not true at all. That's the plan for asm.js, but this demo doesn't run in anything other than very new Firefox builds, AFAICT. It crashes chrome, IE doesn't support WebGL (yet).
It works for example in Firefox 20, the current stable release, which has no special asm.js optimizations.