SlideShare a Scribd company logo
Corey Clark PhD
Daniel Montgomery
Web Dev Platform
Cross
Platform
Cross
Browser
HTML5
WebGL
Web
Socket
Web
Worker
Hardware
Acceleration
Optimized
Communication
Channel
Parallel
Processing
JaHOVA OS
Kernel
Internal APIs
Threading
Network
Graphics
Web
Workers
Web
Sockets
WebGL
Web Workers and Multithreading
§  Parallel Execution
§  Communicates
through Message
§  Executes in
Isolated Thread
● No Access To
●  DOM, Window
●  Document, Parent
●  No Shared Memory
● But You Do Have…
●  XHR / WebSockets
●  Navigator,Location
●  setTimeout/setInterval
●  App Cache, importScript
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games
Time to Create First Worker
•  Varies depending on Worker Size
•  Can take a second to start
•  Initialize at beginning with a startup routine
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games
Web Worker Variations
● Inline vs. External
●  BlobBuilder
●  Inline only supported by FF and Chrome
●  No difference in performance
● Dynamic
●  Method determined at run time from JSON
string
●  Altered and changed by user at run time
Nested Shared
Worker
Nested Worker
Main Thread
Nested Worker
Nested Worker
Window Window
iframe
Shared Worker
Platform Support
● Chrome/Firefox/Safari
●  Chrome/Safari supports Shared Only
●  Firefox supports Nested Only
● Android – (via Firefox and Opera Browser)
● iOS
● IE 10
Command
Module
Internal APIs
Thread
Thread Core
Instruction
Module
Thread
Thread /
iframe
Thread /
iframe
…
Thread
Controller
ThreadThread
Pool
Thread
Manager
Shared
Memory
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games
What is WebGL?
OpengGL ES 2.0
WebGL
The Basics Sample API/Libraries
● JavaScript Wrapper
for OpenGL ES 2.0
● Programmable
Graphics Pipeline
(GLSL)
● Hardware
Acceleration
● SpiderGL
● Copperlicht
● CubicVR
● Gladius
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games
WebGL Hardware Test
Verts Polys Draw FPS CPU RAM Video OS
858,750 485,292 654 30 2.2GHz
Intel i7
Quad
Core
4GB AMD
Radeon
6750M
1GB
OSX
634,179 353,386 483 30 2.53GH
z Intel
Core 2
Duo
4GB NVIDIA
9800+
1GB
Windows
7
590,898 333,924 450 33.33 2.53GH
z Intel
Core 2
Duo
8GB NVIDIA
GeForce
9600M
GT
512MB
OSX
Chrome
Browser vs Browser
Browser Verts Polys Draw Calls
Chrome 590,898 333,924 450
Aurora 426,773 241,174 325
WebKit Nightly 393,948 222,624 300
Safari 295,473 166,974 225
Firefox 262,648 148,424 200
WebGL Tid Bits
Tips Up and coming
● DebugContex
● WebGL Inspector
● requestAnimFrame
● BMP Support
● No IE Support with out
plugins and Hackery
● WebGL Running in
Web Worker
● Swapping Memory
Buffer rather than
copy
+ +
Web Sockets
● Full Duplex Communication
● No HTTP overhead
● Has Secure Transport Protocol
● Cross Origin Communication
● Very Simple Client Side API
●  Socket.onmessage = function(){}
●  Socket.onopen = function(){}
●  Socket.open(), Socket.send(), Socket.close()
Nitty Gritty
● 2 Bytes Overhead Per Message
●  XHR ~871 Bytes
● Constant Connection
●  No need to re-establish connection (COMET)
● Connecting to Non Browser Applications
(via Proxy/Server)
●  Byte Arrays
●  Bit Shifting
Daniel Montgomery
WebSocket Server Side
● Standard HTTP Request/
Response model performs
poorly for high number of
users
● Server Needs
●  Thread or Non
Blocking IO Design
●  High concurrency at
Low Performance cost
● Existing Servers
●  Node.js
●  Jetty (Java)
●  Ruby (Event
Machine)
●  Python (Twisted)
● Google V8 Engine
● JavaScript
● Event Driven
● Event Loop with Callbacks
● Non-Blocking
● Native C++ Bindings
● Fast!!
FEATURES
• WebSocket Server
• Socket.IO
• Kaazing Gateway
• TCP Server
• File Server
• MySQL, MongoDB,
NoSQL
Modules (NPM)
• Well Kept After
• Documented
• Quick Response
• Use existing Git
• npm dependencies
• Fast!
• (“Hello World!” in 1 minute)
Free!!!
FEATURES
Other hosting options…
http://no.de
eSession
("Omega"["gunner"
, "pilot"]);
http://heroku.com
http://nodejitsu.com
http://cloudno.de
JaHOVA OS Server Module
●  Connect to Multiple Applications on
same server
●  Remote Stream Functions
●  User Creation on the fly
●  Support for Multiple Connection Types
●  TCP
●  WebSockets
●  Socket.IO and Express node.js modules
JOSSM: Breakdown
●  Multiple Sessions
●  Multiple Session Types
●  Defined in a single line!
●  Streamed Sessions, Modules, and
Functions
●  Easily add and connect users to
multiple sessions
handler.createSession("Omega", "", ["gunner", "pilot"]);
JOSSM: Session Breakdown
●  Session Specific Properties
●  On Events
●  Open
●  Close
●  Message
●  Error
●  Multiple Modules
●  Remote Module Requests
Engine Architecture
● Dynamic Nested/Shared Web Worker
●  Thread Controller
●  Shared Memory Pool
● Custom Event Management System
● Available Engines
●  Akihabara (2D)
●  Effect Game (2D)
●  Isogenic Engine
●  Johmoho
3rd Party
Extensions
Application
JaHOVA OS
Kernel Internal APIs
Resource and
Schedule Manager
Module
Instruction
Module
Command
Module
Threading
Network
DOM
Graphics
…
Resource and Schedule Manager Module
Event Manager
Event
Manager
Interface
Event Object
Event
Event
…
Event Object
Event
Event
……
Subscriber
Callback
Subscriber
Callback
Subscriber
Callback
Subscriber
Callback
Core
Manager
Command
Module
Resource and
Schedule Manager
Module
Instruction Module
Router
Route
Resource
Instruction Q
Resource
Instruction Q
Resource
Instruction Q
Add Request
…
…
Event
Manager
Core
Manager
Command Module
Resource
Dispatcher
Resource
Dispatcher
Resource
Dispatcher
Engine Demonstration
● WebGL, WebSockets, Web Workers
● HTML5 Audio
● Thread Controller
●  Networking and Physics
● Node.js
●  JaHOVA OS Server Module
●  WebSocket - SocketIO
● Developed in under a week
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games
Final Thoughts
● Initialize Threads at Startup
● Initialization Timing
●  Serialize for dependencies and registration
● Careful with Debuggers and Web Workers
● See more at
●  http://jahovaos.com : Descriptions and Blog
●  http://demo.jahovaos.com : Code
● Expo Floor 2-4 on Wed @ DeVry Booth

More Related Content

PDF
Bringing The Sexy Back To WebWorkers
PPTX
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
PDF
Conquering AngularJS Limitations
PDF
BP101: A Modernized Workflow w/ Domino/XPages
PPTX
Testing your Single Page Application
KEY
Introducing the Seneca MVP framework for Node.js
PDF
Lessons in Open Source from the MongooseJS ODM
PPTX
Blazor - An Introduction
Bringing The Sexy Back To WebWorkers
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Conquering AngularJS Limitations
BP101: A Modernized Workflow w/ Domino/XPages
Testing your Single Page Application
Introducing the Seneca MVP framework for Node.js
Lessons in Open Source from the MongooseJS ODM
Blazor - An Introduction

What's hot (20)

KEY
ClubAJAX Basics - Server Communication
PDF
Introduction to Node.js
PPTX
PHP Indonesia - Nodejs Web Development
PDF
MongoDB MEAN Stack Webinar October 7, 2015
PPTX
Testing Single Page Webapp
PDF
Isomorphic web application
ZIP
Drupal, Android and iPhone
PPTX
In-browser storage and me
PDF
The Dark Side of Single Page Applications
PPTX
PDF
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
KEY
20120306 dublin js
PPSX
Node.js In The Enterprise - A Primer
PDF
MEAN Stack - Google Developers Live 10/03/2013
PPT
Nodejs - Building a RESTful API
PPTX
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
KEY
LinkedIn Mobile: How do we do it?
PDF
TDD a REST API With Node.js and MongoDB
KEY
Flash And Dom
PDF
10 things you should know about django
ClubAJAX Basics - Server Communication
Introduction to Node.js
PHP Indonesia - Nodejs Web Development
MongoDB MEAN Stack Webinar October 7, 2015
Testing Single Page Webapp
Isomorphic web application
Drupal, Android and iPhone
In-browser storage and me
The Dark Side of Single Page Applications
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
20120306 dublin js
Node.js In The Enterprise - A Primer
MEAN Stack - Google Developers Live 10/03/2013
Nodejs - Building a RESTful API
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
LinkedIn Mobile: How do we do it?
TDD a REST API With Node.js and MongoDB
Flash And Dom
10 things you should know about django
Ad

Similar to Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games (20)

PDF
Nodejs - A quick tour (v6)
PDF
HTML5 New Features and Resources
PDF
Node.js Presentation
PDF
Nodejs a-practical-introduction-oredev
KEY
Realtime rocks
PDF
Nodejs - A quick tour (v4)
KEY
Introduction to node.js
PDF
Nodejs - A quick tour (v5)
PDF
Developing realtime apps with Drupal and NodeJS
PPT
Nodejs on 02/22/2012
PDF
Building real time applications with Symfony2
PPTX
Hangouts in 30 minutes Socket.io
PDF
Zing Me Real Time Web Chat Architect
KEY
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
PDF
Integrating Node.js with PHP
PPTX
GeekCampSG - Nodejs , Websockets and Realtime Web
PPTX
WebSockets-Revolutionizing-Real-Time-Communication.pptx
PDF
Node.js scaling in highload
PDF
Dragoncraft Architectural Overview
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
Nodejs - A quick tour (v6)
HTML5 New Features and Resources
Node.js Presentation
Nodejs a-practical-introduction-oredev
Realtime rocks
Nodejs - A quick tour (v4)
Introduction to node.js
Nodejs - A quick tour (v5)
Developing realtime apps with Drupal and NodeJS
Nodejs on 02/22/2012
Building real time applications with Symfony2
Hangouts in 30 minutes Socket.io
Zing Me Real Time Web Chat Architect
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Integrating Node.js with PHP
GeekCampSG - Nodejs , Websockets and Realtime Web
WebSockets-Revolutionizing-Real-Time-Communication.pptx
Node.js scaling in highload
Dragoncraft Architectural Overview
Event-driven IO server-side JavaScript environment based on V8 Engine
Ad

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Cloud computing and distributed systems.
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Electronic commerce courselecture one. Pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
The Rise and Fall of 3GPP – Time for a Sabbatical?
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Cloud computing and distributed systems.
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation
Electronic commerce courselecture one. Pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
“AI and Expert System Decision Support & Business Intelligence Systems”
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks

Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScript To Connect Native and Browser-Based Games

  • 4. Web Workers and Multithreading §  Parallel Execution §  Communicates through Message §  Executes in Isolated Thread ● No Access To ●  DOM, Window ●  Document, Parent ●  No Shared Memory ● But You Do Have… ●  XHR / WebSockets ●  Navigator,Location ●  setTimeout/setInterval ●  App Cache, importScript
  • 6. Time to Create First Worker •  Varies depending on Worker Size •  Can take a second to start •  Initialize at beginning with a startup routine
  • 10. Web Worker Variations ● Inline vs. External ●  BlobBuilder ●  Inline only supported by FF and Chrome ●  No difference in performance ● Dynamic ●  Method determined at run time from JSON string ●  Altered and changed by user at run time
  • 11. Nested Shared Worker Nested Worker Main Thread Nested Worker Nested Worker Window Window iframe Shared Worker
  • 12. Platform Support ● Chrome/Firefox/Safari ●  Chrome/Safari supports Shared Only ●  Firefox supports Nested Only ● Android – (via Firefox and Opera Browser) ● iOS ● IE 10
  • 13. Command Module Internal APIs Thread Thread Core Instruction Module Thread Thread / iframe Thread / iframe … Thread Controller ThreadThread Pool Thread Manager Shared Memory
  • 16. WebGL The Basics Sample API/Libraries ● JavaScript Wrapper for OpenGL ES 2.0 ● Programmable Graphics Pipeline (GLSL) ● Hardware Acceleration ● SpiderGL ● Copperlicht ● CubicVR ● Gladius
  • 18. WebGL Hardware Test Verts Polys Draw FPS CPU RAM Video OS 858,750 485,292 654 30 2.2GHz Intel i7 Quad Core 4GB AMD Radeon 6750M 1GB OSX 634,179 353,386 483 30 2.53GH z Intel Core 2 Duo 4GB NVIDIA 9800+ 1GB Windows 7 590,898 333,924 450 33.33 2.53GH z Intel Core 2 Duo 8GB NVIDIA GeForce 9600M GT 512MB OSX Chrome
  • 19. Browser vs Browser Browser Verts Polys Draw Calls Chrome 590,898 333,924 450 Aurora 426,773 241,174 325 WebKit Nightly 393,948 222,624 300 Safari 295,473 166,974 225 Firefox 262,648 148,424 200
  • 20. WebGL Tid Bits Tips Up and coming ● DebugContex ● WebGL Inspector ● requestAnimFrame ● BMP Support ● No IE Support with out plugins and Hackery ● WebGL Running in Web Worker ● Swapping Memory Buffer rather than copy
  • 21. + +
  • 22. Web Sockets ● Full Duplex Communication ● No HTTP overhead ● Has Secure Transport Protocol ● Cross Origin Communication ● Very Simple Client Side API ●  Socket.onmessage = function(){} ●  Socket.onopen = function(){} ●  Socket.open(), Socket.send(), Socket.close()
  • 23. Nitty Gritty ● 2 Bytes Overhead Per Message ●  XHR ~871 Bytes ● Constant Connection ●  No need to re-establish connection (COMET) ● Connecting to Non Browser Applications (via Proxy/Server) ●  Byte Arrays ●  Bit Shifting
  • 25. WebSocket Server Side ● Standard HTTP Request/ Response model performs poorly for high number of users ● Server Needs ●  Thread or Non Blocking IO Design ●  High concurrency at Low Performance cost ● Existing Servers ●  Node.js ●  Jetty (Java) ●  Ruby (Event Machine) ●  Python (Twisted)
  • 26. ● Google V8 Engine ● JavaScript ● Event Driven ● Event Loop with Callbacks ● Non-Blocking ● Native C++ Bindings ● Fast!! FEATURES • WebSocket Server • Socket.IO • Kaazing Gateway • TCP Server • File Server • MySQL, MongoDB, NoSQL Modules (NPM)
  • 27. • Well Kept After • Documented • Quick Response • Use existing Git • npm dependencies • Fast! • (“Hello World!” in 1 minute) Free!!! FEATURES
  • 28. Other hosting options… http://no.de eSession ("Omega"["gunner" , "pilot"]); http://heroku.com http://nodejitsu.com http://cloudno.de
  • 29. JaHOVA OS Server Module ●  Connect to Multiple Applications on same server ●  Remote Stream Functions ●  User Creation on the fly ●  Support for Multiple Connection Types ●  TCP ●  WebSockets ●  Socket.IO and Express node.js modules
  • 30. JOSSM: Breakdown ●  Multiple Sessions ●  Multiple Session Types ●  Defined in a single line! ●  Streamed Sessions, Modules, and Functions ●  Easily add and connect users to multiple sessions handler.createSession("Omega", "", ["gunner", "pilot"]);
  • 31. JOSSM: Session Breakdown ●  Session Specific Properties ●  On Events ●  Open ●  Close ●  Message ●  Error ●  Multiple Modules ●  Remote Module Requests
  • 32. Engine Architecture ● Dynamic Nested/Shared Web Worker ●  Thread Controller ●  Shared Memory Pool ● Custom Event Management System ● Available Engines ●  Akihabara (2D) ●  Effect Game (2D) ●  Isogenic Engine ●  Johmoho
  • 33. 3rd Party Extensions Application JaHOVA OS Kernel Internal APIs Resource and Schedule Manager Module Instruction Module Command Module Threading Network DOM Graphics …
  • 34. Resource and Schedule Manager Module Event Manager Event Manager Interface Event Object Event Event … Event Object Event Event …… Subscriber Callback Subscriber Callback Subscriber Callback Subscriber Callback Core Manager Command Module
  • 35. Resource and Schedule Manager Module Instruction Module Router Route Resource Instruction Q Resource Instruction Q Resource Instruction Q Add Request … … Event Manager Core Manager Command Module Resource Dispatcher Resource Dispatcher Resource Dispatcher
  • 36. Engine Demonstration ● WebGL, WebSockets, Web Workers ● HTML5 Audio ● Thread Controller ●  Networking and Physics ● Node.js ●  JaHOVA OS Server Module ●  WebSocket - SocketIO ● Developed in under a week
  • 38. Final Thoughts ● Initialize Threads at Startup ● Initialization Timing ●  Serialize for dependencies and registration ● Careful with Debuggers and Web Workers ● See more at ●  http://jahovaos.com : Descriptions and Blog ●  http://demo.jahovaos.com : Code ● Expo Floor 2-4 on Wed @ DeVry Booth