WebGL arrives on iOS 8 - and more

1
Official Construct Post
Ashley's avatar
Ashley
  • 4 Jun, 2014
  • 971 words
  • ~4-6 mins
  • 3,150 visits
  • 0 favourites

It's been a great week for HTML5 gaming news. Finally it's confirmed that Safari on iOS 8 will support WebGL! Safari was the last major browser without support, so this pretty much completes the set.

In case you didn't know, Construct 2 supports two renderers: a basic no-frills "canvas2d" renderer, and a low-level OpenGL-based WebGL renderer. The WebGL renderer is chosen first if it's available because WebGL mode is a lot faster and it supports awesome visual effects. This means faster and better looking games from iOS 8. On an iPhone 4S we've seen the Space Blaster performance test get topped up from 40 FPS to 58 FPS, and other demos with heavy use of particles or tiled backgrounds going from under 20 FPS to a solid 60 FPS. This is huge - finally the true performance of the often powerful iOS devices has been unlocked!

When iOS 8 rolls around later this year, the latest versions of all the major desktop and mobile browsers will support WebGL, including Internet Explorer, Windows Phone, iOS, and Chrome for Android. It's been nearly 3 years since we first introduced the WebGL renderer for Construct 2, and at the time it only worked on desktop Chrome and Firefox - and having it on mobile seemed like a distant dream. The progress since then has been pretty stunning.

It gets better: faster web view

Conventional wisdom for a couple of years now has been "don't use PhoneGap - it's far too slow, use specially accelerated non-browser wrappers instead". This will change with iOS 8 as well. The reason PhoneGap used to be slow is because showing a HTML5 game in a native app required using a web view control, and that control did not have the full performance of the browser, lacking GPU acceleration (making rendering incredibly slow) and not allowing JIT-compilation of Javascript (making the game logic slower). iOS 8 fixes this. The web view control in native apps can use GPU-accelerated WebGL and JIT-compile Javascript for maximum performance - making it on equal terms with the Safari browser.

And better: faster Javascript

Recently the Safari engineers announced a very impressive addition to their Javascript engine: the Fourth Tier LLVM (FTL) JIT. The linked blog post is deeply technical and outlines a quite extraordinary engineering achievement if you understand the details. However in short there's a new layer in the Javascript engine which optimises the code with a full-blown native-grade compiler (LLVM). This is more traditionally used with native languages like C and C++, but now helps power their Javascript engine. On top of that it compiles in parallel, so the game isn't held up having to wait for compilation to finish. And all this runs in the web view as well!

Another indirect benefit is other browser makers probably won't like to be out-done - so this could spur on further progress in speeding up other Javascript engines even more.

Android is improving too

At pretty much the same time, Android has been fixing up its web view along similar lines. Android 4.4 (KitKat) introduced a Chrome-powered web view for native apps, and it's always been able to JIT-compile Javascript for best performance, but it still didn't have GPU acceleration for games. Android 4.4.3 adds GPU acceleration for canvas2d and support for GPU-accelerated WebGL is being worked on, and seems likely to make a near future Android release. In short this means the same will be true of native apps on Android: they will have the same performance and features as the Chrome browser, even from PhoneGap or other web view controls.

Android has generally had a rather sedate rate of distributing updates, so it may take longer than iOS for these updates to get a wide foothold in the Android world. However it will happen eventually, and in the mean time there's Crosswalk that essentially can do the same thing already.

The end of wrappers

Non-browser wrappers have generally only been necessary on iOS and Android, and only really iOS since the introduction of Crosswalk for Android. All other platforms already perform well, even from native apps. Wrappers often prove a bit of a headache for compatibility: typically various browser features are missing, like the ability to use form controls, XML parsing, web fonts, Web Audio API features (like advanced audio effects), sensible memory management, or the letterbox scale modes. The improvements in iOS and Android mean we will soon be able to do away with these technologies entirely and rely on real, fully-capable browser engines to power games in native mobile apps. Then the conventional wisdom of "don't rely on PhoneGap or web view controls" can be thrown away, since those technologies can be relied on to provide great results as well.

The web is the platform

When we first got going with Construct 2, it was before any browser has GPU acceleration, and IE8 was still the latest and greatest from Microsoft without any HTML5 support at all. Our focus was to build a tool that could produce HTML5 games that surpassed the old clunky Flash games that were previously popular. We think we've achieved that, but at the same time it's become less relevant. We have been amazed at the progress over the past couple of years as powerful, capable and surprisingly cheap mobile devices have become prevalent, new stores with HTML5 support have appeared (including some very significant additions like the Windows Store) and even consoles have started to support HTML5 as a way of producing beautiful and immersive high-resolution games, and there are even now entire HTML5-only devices like the Chromebook and Firefox OS. We've never been more confident in the ability of HTML5 to provide highly compatible multiplatform native-grade gaming experiences, and we are looking forwards to the further developments still to come in the future.

Subscribe

Get emailed when there are new posts!