Introducing on-demand views in Coherent UI
Coherent UI is designed as a multi-process multi-threaded module to allow leveraging on modern processors and GPUs. Up until now it supported what we call ‘buffered‘ views. All UI rendering is performed in an apposite rendering process that allows sand-boxing the interface’s operations, hence all commands are executed asynchronously.
This kind of views allow for perfectly smooth animations and user experience and are the natural choice for dynamic UIs and in-game browser views. However, if you need to have interface elements correlate per-frame with in-game entities, buffered views might not be suitable.
Take for instance enemy players in an MMO – their nameplates must always be perfectly snapped in every frame over their heads. The same applies to RTS games – health indicators must be glued on the units and never lag behind.
Coherent UI is now the only HTML5-based solution that solves all these problems. We have created what we call ‘on-demand‘ views. They allow exact synchronization between the game frame and the out-of-process UI rendering without sacrificing any performance. Everything is still asynchronous but we make strong guarantees on the content of frames you receive at any point.
With on-demand views the game can explicitly request the rendering of UI frames and is guaranteed that all events prior to the request will be executed in that frame.
The typical frame of a game that uses on-demand views looks like this:
- update frame (move players, AI, etc.)
- trigger UI events (i.e. set the new nameplates positions, player health, etc.)
- request UI frame
- draw game frame
- fetch UI frame
- compose UI on the game frame
This flow ensures that the game is in perfect sync with the UI and while the game renders it’s frame the UI gets simultaneously drawn in Coherent UI’s internals.
This video shows the new view in action. Please, do not mind the programmer art.
As you can see buffered views might introduce some delay that is noticeable if interface elements are related to in-game events as the position of the units. On-demand views remain always in-sync.
Buffered views will remain part of Coherent UI as they are very easy to use and should be the default choice when no frame-perfect visual synchronization is required between the game and the UI. For instance if have an FPS game and the UI only shows mini-map, player health and ammo you should probably use buffered views as no delay will ever be noticeable on the elements you are showing. The same applies to in-game browsers.
In other cases however on-demand views come to aid. They will be available for use in the next version of Coherent UI.
Follow Stoyan on Twitter: @stoyannk