

Unreal JavaScript - ndr
http://blog.bitops.com/blog/2013/05/01/unreal-javascript/

======
beaumartinez
Slight nitpick, but this is _Unreal Engine 3_ , not Unreal, the 1998 PC
FPS[1].

That game blew me away when I was younger—the graphics were truly stellar,
better than Quake 2 and Half-Life, games released at the same time—and for a
moment I thought someone had managed to port it to JavaScript.

I would pay good money to play it in my browser.

[1] <http://en.wikipedia.org/wiki/Unreal>

~~~
jokoon
can you explain to me why would it be a better news ?

~~~
oconnor0
I was impressed that Unreal was running in the browser via Javascript. Unreal
Engine 3 is a much more resource intensive engine so that being able to run in
the browser is even more impressive.

~~~
jokoon
oh ok I thought you were saying "damn it's not unreal 1, it's unreal 3".

------
idm
I actually exclaimed "UNREAL!" when I launched this in Firefox Aurora. I was
expecting Engine 1, but I see now it's Unreal Engine 3. WOW.

If that's not proof that asm.js is a cool concept, then I don't know what is.

I don't understand how they're making this so freaking fast; they've done some
special work to get it running with WebGL.

> We’ve had success in running it in other browsers, but it’s somewhat hit and
> miss – it heavily depends on the quality of the WebGL implementation, memory
> management, and JavaScript engine

Anyway, Firefox does a great job with it. I'm impressed.

------
dexen
Just think of how far we got in recent years: C++ code compiled to asm.js,
JITted and running in browser running on OS running in virtual machine running
on OS running on a microcoded CPU -- and GLSL shaders compiled to ARB, running
on microcoded GPU.

Next thing you know, antivirus software for web browsers (sic) will become the
norm.

~~~
TazeTSchnitzel
Why would web browsers need anti-virus software? It's not really a problem,
since the web's APIs enforce a lot of sandboxing and hence security.

~~~
quux
WebGL is pretty scary since it's only a thin wrapper around OpenGL. OpenGL
drivers tend to run in the kernel, have direct access to the complete memory
of the box and not be hardened from a security perspective. It's only a matter
of time before someone figures out a way to own a box via WebGL by simply
visiting a website. This is why Apple leaves WebGL disabled by default in
Safari, and I think Microsoft is hesitant to add support in IE for the same
reason.

~~~
gcr
I agree. There was a recent time - maybe a few months ago - where Linux with
nvidia hardware and their binary driver blob would instantly panic the system
when I visited a page in firefox that used webGL shaders.

------
overgard
Ok so first, I'll just say, this is cool. I'm pretty excited about asm.js in
general.

I'm sort of skeptical when they say they ported "Unreal" though. What I see
there is an Unreal map viewer. I don't see any physics or AI or sound going
on. The thing is about doing a map viewer, pretty much all the work is going
to the graphics card, so it really doesn't matter what language you use. I
think I'll be more excited when I see a demo that actually plays like a full
game.

~~~
vrodic
If you look at the video you'll see they have full gameplay with bots.
Presumably they still have some bugs to iron out or are working on how to
present the whole thing to users as a playable game on the web.

~~~
azakai
I don't think there are any bugs, we showed that map with bots in a booth at
GDC 2013 where people could play it. Worked fine.

------
dmpk2k
How are threads handled? The standard Unreal engine isn't single-threaded.

~~~
MasterScrat
Emscripten uses web workers to compile multithreaded code, provided they don't
use shared states (which isn't doable in JS).

~~~
iso8859-1
Do you know where I can find documentation for that?

------
xuhu
I could start it in nightly on linux but with low framerate. On windows I see
this in the console (and it stops at "preparing javascript"):

    
    
        [15:16:42.533] TypeError: asm.js type error: Internal codegen failure (probably out of memory) @ http://www.unrealengine.com/html5/UDKGame-Browser-Shipping.js:9649
        [15:16:50.798] out of memory

~~~
TazeTSchnitzel
How much RAM does your machine have? How much was used by other
tabs/applications?

~~~
xuhu
Very late reply, but I tried win7 x64 and x86 with 4GB. Taskmgr shows the ram
usage jump from 900MB to 2.5GB after a fresh reboot.

I tried downloading the entire page (html,css,js) and increasing TOTAL_MEMORY
(et al) in the js, but with the same result.

Nightly-23 from 07 May (firefox-20.1, same result). It did work on ubuntu-
amd64 though.

------
vrodic
If you're per chance running on Linux/Intel/IvyBridge, it can be even faster
than on Windows:

Details:

Windows 7 (latest Intel GPU drivers), Firefox 23 nightly

Ubuntu 13.04 with custom Mesa git (Mesa 9.1 also works, but a bit slower),
Firefox 23 nightly

I had to set layers.acceleration.force-enabled variable to true in Firefox (in
about:config) because it is blacklisted for some reason on Linux/Intel
(probably some previously resolved bug).

The browser Window was maximized in 1920x1080, and game view was not full-
screened.

Cpu is i5-3320M on Thinkpad X230

Windows: 40.5 FPS Linux: 43.6 FPS

------
paraboul
_with asm.js_

Did you mean _with_ emscripten _to_ asm.js

~~~
Stranger2013
It should really be named as 'web bytecode' or 'web assembly'.

~~~
weego
Should they? Both terms appear to not make much sense even in context, and
also appear from a quick google search to have no provenance at all.

~~~
arethuza
To be fair, the _idea_ of distributing executable bytecode to be run by some
kind of VM in browsers has been around for almost as long as the web has
(predating even Java), even if there never was a standard name for it.

~~~
MasterScrat
Sure, but that's just not what's being used here.

------
melling
Where's the solution that enterprises can use to build their remaining desktop
apps into the browser? People still write native Windows apps, for example, to
get performance in large grids with filtering.

A solution is missing that fits between C++ and Javascript.

~~~
arethuza
You could argue that Citrix and Terminal Services do a reasonable job of
delivering existing desktop apps to remote users (even in a browser).

Now, of course, there are a lot of advantages to having things really working
in a browser - less sensitivity to latency sometimes being a critical one. But
there are a lot of enterprises using remote access to thick client
applications, even some specialised SaaS vendors.

~~~
melling
Ok, that's fine for legacy, but what should enterprise do about new apps?
Continue to build desktop apps and deliver with Citrix?

~~~
arethuza
Apart from some specialised scenarios (e.g. direct interfacing with directly
attached devices) then web applications are clearly the way to go for newly
written applications. However, I would be very reluctant to describe anything
non-Web as "legacy" - enterprises will happily (and rightly) still buy desktop
applications if they are the best tool for the job - and these need Citrix or
Terminal Services.

------
jebblue
It's impressive but runs at 19 FPS on my new desktop with a GTX 660 card. It's
still slower than I've seen that demo running on a phone. People are doing
amazing things with HTML5 and JavaScript but the performance is always behind
a native application, even a Java application.

~~~
azakai
FPS really depends on which browser you are on.

Since you mentioned Java, note that in some cases JavaScript with asm.js can
be faster, for example <http://j15r.com/blog/2013/04/25/Box2d_Revisited>

~~~
iso8859-1
If someone gave JBox2D the same amount of attention box2d.js got to win this
benchmark, I suggest that the results would look different. Correct me if I'm
wrong, but it seems like box2d.js was made and optimized just prior to this
benchmark, while JBox2D is an old project that was never meant to win any
benchmarks.

------
runarb
Sounds uber cool, but don't work in Chrome. The tab just crashed...

Will it be much jobb to make this work in all browsers?

~~~
adlpz
Well yes, as this is compiled for asm.js-capable browsers (i.e. Firefox for
now), it will be so slow on anything else that it will just crash.

~~~
cliffbean
You can run it in non-asm.js browsers; the released version of Firefox can run
it, for example. It doesn't crash, but it is slower. According to the FAQ on
the game site [0], Chrome has a bug which is expected to be fixed soon.

[0] <http://www.unrealengine.com/html5_faq/>

------
niggler
What happened to the original title "Unreal JavaScript"? The biggest focus of
the article is emscripten, not asm.js.

------
kyberias
I downloaded latest Nightly for Windows but it still doesn't open. Tells me to
download Nightly which I did. :(

~~~
kylek
works great in aurora for me (fps caps at 60...whoa)

------
shocks
Very cool. Running very smoothly for me.

