Platform/AreWeFunYet

From MozillaWiki
< Platform
Revision as of 00:35, 8 January 2012 by Bjacob (talk | contribs)
Jump to navigation Jump to search

This page tracks the status of Gecko as a games platform.

Also see HTML5 Games.

Tracking Bug for Game Related Issues: https://bugzilla.mozilla.org/show_bug.cgi?id=gecko-gaming

Fast code

Web technology: JavaScript

Competition:

  • ActionScript in Flash
  • C# in Silverlight

JavaScript has been speed up by orders of magnitude over the past few years.

Here is a benchmark comparing ActionScript to several JavaScript engines. It shows that as of June 2011, JavaScript is faster than Flash 10.3 in all major browsers.

TODO: Find/generate more benchmarks? At least update that one to include Flash 11 and the latest JS engines (Firefox 9 with TI) ?

Known Issues

Garbage collection pauses

The main bug to track in this respect is bug 619558: Generational GC. This should solve most of our problems in this area.

In order to maintain smoothness, talks at the New Game Conference discussed the need to minimize load on the JS garbage collector.

  • Improving the speed of GC or good incremental GC (see above bug, generational GC) could solve this.
  • This leads to reusing objects by assigning them to static/global variables.
  • Ability to manually free objects would also work.

Impact of other tabs

See bug 710359. In the web-gaming era, it will not be tolerable that just having a GMail tab on the side severely harms FPS in a game in another tab. This should have been solved by electrolysis ( = process separation), but it's on hold. We need to figure if electrolysis is the only thing to do about that, or if there are other things we can to to alleviate this in the short term.

Performance issues with large JS files

See bug 644244. Large JavaScript files (which are not uncommon in games) can in some cases run slowly. Some new benchmarks with large files might help here.

Fast/3D Graphics

Web technology: WebGL.

WebGL is enabled by default in Firefox (4+), Chrome (9+), Opera (12+) on all desktop operating systems and Android. It is available but not enabled by default in Safari 5.1, and available for ads on iOS.

Competition:

  • Stage3D in Flash 11
  • XNA 3D in Silverlight 5
  • Unity3D

The first two graphics APIs are very comparable since they stay very close to OpenGL ES 2.0 functionality (or Direct3D equivalent). WebGL has some extra flexibility and advanced features (more general shaders than Flash and Silverlight, bigger textures than Flash, etc). WebGL does not yet have compressed textures, however this is under discussion and an experimental extension has already been drafted.

There shouldn't exist any meaningful speed differences between these 3D APIs per se. Speed differences would more likely be caused by language/compiler differences (JS vs AS, etc).

Audio

TODO: fill this section

  • Mozilla has a Audio Data API; WebKit has Web Audio API; provide links; discuss ongoing convergence efforts?
    • Is our own Audio Data API really up to the task? 3D positional sound is a requirement.
  • implementation status in browsers?
  • equivalent in Flash, Silverlight?
  • Talks at New Game Conference pointed to WebKit's Web Audio API as the best of the existing solutions.
    • It has lower latency, and more powerful out-of-the-box.
  • Android Audio Notes has a transcript and links from a super informative discussion with Randall Jesup and Kinetik about the state of Android audio as of November, 2011.

FullScreen

This feature allows you to build a web application that runs full screen. This includes any HTML element so you can build full screen games, full interactive video experiences, presentation software or anything else that should dominate the experience.

MouseLock

Web technology: Mouse Lock API

The Mouse Lock API is currently under development by David Humphrey and his students at Seneca College. It is also under development in Chrome. This API is currently in W3C Draft Status.

  • This is targeted to land in the first quarter 2012

Relevant links:

Gamepad

Web technology: GamepadAPI.

The Gamepad API is currently under development in Firefox and Chrome. Firefox builds are available for download here. Chromium builds need to have --enable-gamepad (?) passed on start-up. This API is currently in W3C draft status

  • This is targeted to land in the first quarter 2012

Relevant links:

Keyboard input that ignores keyboard layouts

Many games use the WASD keys for direction control. However, depending on the active keyboard layout, their usual (US-layout) key places can be occupied by different letters. In the AZERTY keyboard layout, for example, these keys have the letters ZQSD, and in Dvorak {comma}AOE.

Users of those keyboard layouts shouldn't need to reconfigure their key mapping or change the system's keyboard layout. Instead, the game should be able to get a pressed key's absolute position on the keyboard, or its "scan code". Key events don't provide that information yet.

I'm not aware of any standardization effort on this.

Competition:

  • unknown

Relevant links:

Local file storage

TODO: fill this section

IndexedDB is an API for client-side storage of significant amounts of structured data and for high performance searches on this data using indexes. While DOM Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution.

IndexedDB provides separate APIs for synchronous and asynchronous access. The synchronous API is intended to be used inside workers.

WebSockets

WebSockets is a bi-directional connection-oriented reliable-transport protocol designed to give an option to developers for low-latency communications between browsers and servers. It isn't a raw socket protocol for security reasons, and is initiated on HTTP ports via an HTTP upgrade.

You can actually do most of what WebSockets does over normal HTTP with long-hanging gets. However, the overhead of doing that over HTTP means that for small transactions - think key strokes, or a few bytes at a time - can have quite a bit of overhead because of HTTP headers. So WebSockets is really built for applications that require low-latency communications. Think live games or keystroke-based interactive applications.

The low-level WebSockets protocol is RFC 6455 and is fully implemented in Firefox 11. The protocol is TCP-based and can use SSL or operate in the clear. Messages are framed with length and can be either binary or UTF-8. Messages sent by the browser are obfuscated on the wire with a key known to the browser and the server, but is not available to JavaScript. This feature exists to prevent some attacks against transparent proxy servers which may intercept the initial WebSocket connection.

There is a separate WebSockets API maintained at the W3C. (The editor's draft is the best source of information and contains the most recent API. The API is message-based. That is, individual WebSocket frames are sent as messages via an event handler in JavaScript. Messages can be handled as strings, ArrayBuffers or Blobs.

As of Firefox 11 we've unprefixed the WebSockets API. This means that we don't expect the protocol or the API to change.

Asset loading/unloading/streaming

From a game developer: "A robust resource/asset loading/unloading/streaming system - The browser is capable of doing a whole lot on this end, particularly streaming and fetching from remote sources. However, a game developer's problem isn't just obtaining and loading the assets, it's managing them from a memory and "readyness" point of view. This is especially key in mobile spaces where you are severely constrained by memory and the traditional mindset of "load all of a level's assets at start and play" begins to break down."

Device orientation control

Ability to block, define and get informed when the device orientation changes. Basic use case is for a game that has to be played in landscape mode. The game should lock the orientation to landscape mode even if the device is currently in portrait mode.

TODO: fill this section

  • link to a spec for the web
  • equivalent in Flash, Silverlight, iOS, Android?

Game-oriented documentation

TODO: fill this section

  • Tutorials
  • Example games
  • Articles in Gamedev.net, Gamasutra, etc.