SlideShare a Scribd company logo
Typed Arrays
      Binary Data in the Browser

2012.09.19, 동국대 멀티미디어공학과 이창환
Contents
       Introduction
       Basics of using Typed Arrays
       Browser APIs that use Typed Arrays
       Third-party libraries
       History of Typed Arrays
       Design considerations
       References




    2
Introduction
       The need to have an efficient way to handle binary data in WebGL.

       A slab of memory with a typed view into it
           Like how arrays work in C.
           The JavaScript engine can pass the memory directly to native libraries
           Better than JavaScript arrays for passing data to WebGL and other APIs dealing with
            binary data.


       Typed array views
           Single-type arrays to a segment of an ArrayBuffer.
           Views for all the usual numeric types
               Float32Array, Float64Array, Int32Array and Uint8Array.
           Special view Uint8ClampedArray
               The pixel array type in Canvas's ImageData


       DataView
           Handling heterogeneous data.
           A get/set API to read and write arbitrary data types at arbitrary byte offsets.
           Reading and writing file headers and other such struct-like data.



    3
Introduction

                  JavaScript               Native

Single    Value: 123                     Value: 123
Value    Type: integer


             [0]          Value: 123      [0]:123
             [1]         Type: integer    [1]:123
             [2]                          [2]:123
                          Value: 123
Values       [3]
                         Type: integer    [3]:123
  in         [4]                          [4]:123
             [5]               …          [5]:123
 Array        …                             …
            [n-2]         Value: 123     [n-2]:123
            [n-1]        Type: integer   [n-1]:123


 4
Basics of using Typed Arrays
       Typed array views
       DataView
       A discussion of endianness




    5
Typed Array Views
       To use Typed Arrays
           Create an ArrayBuffer and a view to it




    6
Typed Array Views
       Create an ArrayBuffer and views that point to it.




       Copy a typed array to another typed array
           set() method




    7
DataView
       DataView to the buffer
           To use ArrayBuffers that contain data with
            heterogenous types




           Endian: optional littleEndian parameter




    8
DataView
       Writing values to buffers




    9
A Discussion of Endianness
    Endianness, or byte order
        big-endian: the most significant byte first
        little-endian: the least significant byte first.




    10
Browser APIs that use Typed Arrays
    WebGL
    Canvas 2D
    XMLHttpRequest2
    File APIs
    Transferable objects
    Media Source API
    Binary WebSockets




    11
Third-party libraries
    jDataView
    stringencoding
    BitView.js
    DataStream.js




    12
History of Typed Arrays
    Start in the early implementation stage of WebGL
        JavaScript arrays  Native array
        Allocate a native array
        Fill it by walking over the JavaScript array
        Cast every JavaScript object in the array to the required native type.

    Mozilla's Vladimir Vukicevic
        CanvasFloatArray: a C-style float array with a JavaScript interface

    Renamed WebGLFloatArray

    Renamed Float32Array
        split into a backing ArrayBuffer and the typed Float32Array-view to
         access the buffer.
        Types were added for other integer and floating-point sizes and
         signed/unsigned variants.


    13
Design considerations
    Design of Typed Arrays
        Need to efficiently pass binary data to native libraries.
        The typed array views operate upon aligned data in the host
         CPU’s native endianness.

    DataView
        Designed for file and network I/O

    The design split
        in-memory data assembly (using the typed array views)
        I/O (using DataView)

    Modern JavaScript engines
        Optimize the typed array views heavily
        Achieve high performance on numerical operations

    14
References
    [1] http://www.khronos.org/registry/typedarray/specs/latest/
    [2] https://developer.mozilla.org/en/JavaScript_typed_arrays
    [3] http://blogs.msdn.com/b/ie/archive/2011/12/01/working-
     with-binary-data-using-typed-arrays.aspx
    [4] http://weblog.bocoup.com/javascript-typed-arrays/
    [5] http://blog.n01se.net/?p=248
    [6] http://ie.microsoft.com/testdrive/HTML5/TypedArrays/
    [7] TYPED ARRAYS: BINARY DATA IN THE BROWSER,
     http://www.html5rocks.com/en/tutorials/webgl/typed_arrays/




    15

More Related Content

PDF
Adding new type to Druid
PPSX
Object Class
PPT
2CPP16 - STL
PPTX
Session 14 - Object Class
PPTX
Understanding the components of standard template library
PPT
Reflection
PPTX
Session 17 - Collections - Lists, Sets
PDF
[Webinar] Scientific Computation and Data Visualization with Ruby
Adding new type to Druid
Object Class
2CPP16 - STL
Session 14 - Object Class
Understanding the components of standard template library
Reflection
Session 17 - Collections - Lists, Sets
[Webinar] Scientific Computation and Data Visualization with Ruby

What's hot (20)

PDF
Sperasoft‬ talks j point 2015
PPSX
Collections - Sorting, Comparing Basics
PPTX
Session 15 - Collections - Array List
PPTX
Session 05 - Strings in Java
ODP
Sysprog 9
PPTX
Session 20 - Collections - Maps
PDF
STL in C++
PDF
Java basic datatypes
PPTX
Standard Template Library
PPSX
Collections - Maps
PPSX
Strings in Java
PPT
standard template library(STL) in C++
PDF
An Introduction to the C++ Standard Library
PPTX
Collections Array list
PPSX
Collections - Array List
PPT
Stl (standard template library)
PPSX
Collections - Lists, Sets
PDF
Files and data storage
PDF
Standard template library
PPT
Standard Template Library
Sperasoft‬ talks j point 2015
Collections - Sorting, Comparing Basics
Session 15 - Collections - Array List
Session 05 - Strings in Java
Sysprog 9
Session 20 - Collections - Maps
STL in C++
Java basic datatypes
Standard Template Library
Collections - Maps
Strings in Java
standard template library(STL) in C++
An Introduction to the C++ Standard Library
Collections Array list
Collections - Array List
Stl (standard template library)
Collections - Lists, Sets
Files and data storage
Standard template library
Standard Template Library
Ad

Viewers also liked (7)

PDF
Web sessions in Developer Conferences
PDF
JavaScript Engine and WebAssembly
PDF
Designing Teams for Emerging Challenges
PDF
UX, ethnography and possibilities: for Libraries, Museums and Archives
PDF
Visual Design with Data
PDF
3 Things Every Sales Team Needs to Be Thinking About in 2017
PDF
How to Become a Thought Leader in Your Niche
Web sessions in Developer Conferences
JavaScript Engine and WebAssembly
Designing Teams for Emerging Challenges
UX, ethnography and possibilities: for Libraries, Museums and Archives
Visual Design with Data
3 Things Every Sales Team Needs to Be Thinking About in 2017
How to Become a Thought Leader in Your Niche
Ad

Similar to W3C HTML5 KIG-Typed Arrays (20)

PDF
JavaOne 2013: Memory Efficient Java
PDF
PPT
.Net 3.5
PPTX
Net framework
PPTX
.Net Framework Introduction
PPT
File handling
PPTX
Introduction to System verilog
PDF
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
PDF
advancedvlsisystemverilogbychinnifinal-201114060759.pdf
PDF
.Net Classes and Objects | UiPath Community
PDF
Time Series to Vectors: Leveraging InfluxDB and Milvus for Similarity Search
PDF
WebGL 2.0 Reference Guide
PDF
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams
PPTX
Certification preparation - Net classses and functions.pptx
PPTX
Mongo db Quick Guide
PPTX
js.pptx
PPTX
How Netflix Uses Data Abstraction to Operate Services at Scale - Vidhya Arvin...
PDF
Dotnet content
PPTX
Umbraco OktoberFest 2014
PPTX
JavaOne 2013: Memory Efficient Java
.Net 3.5
Net framework
.Net Framework Introduction
File handling
Introduction to System verilog
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams ...
advancedvlsisystemverilogbychinnifinal-201114060759.pdf
.Net Classes and Objects | UiPath Community
Time Series to Vectors: Leveraging InfluxDB and Milvus for Similarity Search
WebGL 2.0 Reference Guide
Safe Automated Refactoring for Intelligent Parallelization of Java 8 Streams
Certification preparation - Net classses and functions.pptx
Mongo db Quick Guide
js.pptx
How Netflix Uses Data Abstraction to Operate Services at Scale - Vidhya Arvin...
Dotnet content
Umbraco OktoberFest 2014

More from Changhwan Yi (13)

PDF
2013 W3C HTML5 Day Conferences:HTML5 Game App 개발 및 이슈
PDF
Html5 게임 기술의 개요
PDF
동국대 앱창작터 5일차:Cocos2d-X 확장기능
PDF
동국대 앱창작터 4일차:Cocos2d-X 고급기능
PDF
동국대 앱창작터 2일차:Cocos2d-X 기본기능
PDF
동국대 앱창작터 1일차:Cocos2d-X 소개, 환경설정, 주요개념
PDF
W3C HTML5 KIG-The near future of the web platform
PDF
W3C HTML5 KIG-The complete guide to building html5 games
PDF
차세대 웹비즈니스를 위한 "HTML5"
PDF
WoO 2012-Web 서비스 기술
PDF
하이브리드 앱(Hybrid App)
KEY
W3C HTML5 KIG-How to write low garbage real-time javascript
PDF
W3C HTML5 KIG-HTML5 Game Performance Issue
2013 W3C HTML5 Day Conferences:HTML5 Game App 개발 및 이슈
Html5 게임 기술의 개요
동국대 앱창작터 5일차:Cocos2d-X 확장기능
동국대 앱창작터 4일차:Cocos2d-X 고급기능
동국대 앱창작터 2일차:Cocos2d-X 기본기능
동국대 앱창작터 1일차:Cocos2d-X 소개, 환경설정, 주요개념
W3C HTML5 KIG-The near future of the web platform
W3C HTML5 KIG-The complete guide to building html5 games
차세대 웹비즈니스를 위한 "HTML5"
WoO 2012-Web 서비스 기술
하이브리드 앱(Hybrid App)
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-HTML5 Game Performance Issue

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Approach and Philosophy of On baking technology
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Big Data Technologies - Introduction.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology
The Rise and Fall of 3GPP – Time for a Sabbatical?
Network Security Unit 5.pdf for BCA BBA.
Big Data Technologies - Introduction.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The AUB Centre for AI in Media Proposal.docx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Programs and apps: productivity, graphics, security and other tools

W3C HTML5 KIG-Typed Arrays

  • 1. Typed Arrays Binary Data in the Browser 2012.09.19, 동국대 멀티미디어공학과 이창환
  • 2. Contents  Introduction  Basics of using Typed Arrays  Browser APIs that use Typed Arrays  Third-party libraries  History of Typed Arrays  Design considerations  References 2
  • 3. Introduction  The need to have an efficient way to handle binary data in WebGL.  A slab of memory with a typed view into it  Like how arrays work in C.  The JavaScript engine can pass the memory directly to native libraries  Better than JavaScript arrays for passing data to WebGL and other APIs dealing with binary data.  Typed array views  Single-type arrays to a segment of an ArrayBuffer.  Views for all the usual numeric types  Float32Array, Float64Array, Int32Array and Uint8Array.  Special view Uint8ClampedArray  The pixel array type in Canvas's ImageData  DataView  Handling heterogeneous data.  A get/set API to read and write arbitrary data types at arbitrary byte offsets.  Reading and writing file headers and other such struct-like data. 3
  • 4. Introduction JavaScript Native Single Value: 123 Value: 123 Value Type: integer [0] Value: 123 [0]:123 [1] Type: integer [1]:123 [2] [2]:123 Value: 123 Values [3] Type: integer [3]:123 in [4] [4]:123 [5] … [5]:123 Array … … [n-2] Value: 123 [n-2]:123 [n-1] Type: integer [n-1]:123 4
  • 5. Basics of using Typed Arrays  Typed array views  DataView  A discussion of endianness 5
  • 6. Typed Array Views  To use Typed Arrays  Create an ArrayBuffer and a view to it 6
  • 7. Typed Array Views  Create an ArrayBuffer and views that point to it.  Copy a typed array to another typed array  set() method 7
  • 8. DataView  DataView to the buffer  To use ArrayBuffers that contain data with heterogenous types  Endian: optional littleEndian parameter 8
  • 9. DataView  Writing values to buffers 9
  • 10. A Discussion of Endianness  Endianness, or byte order  big-endian: the most significant byte first  little-endian: the least significant byte first. 10
  • 11. Browser APIs that use Typed Arrays  WebGL  Canvas 2D  XMLHttpRequest2  File APIs  Transferable objects  Media Source API  Binary WebSockets 11
  • 12. Third-party libraries  jDataView  stringencoding  BitView.js  DataStream.js 12
  • 13. History of Typed Arrays  Start in the early implementation stage of WebGL  JavaScript arrays  Native array  Allocate a native array  Fill it by walking over the JavaScript array  Cast every JavaScript object in the array to the required native type.  Mozilla's Vladimir Vukicevic  CanvasFloatArray: a C-style float array with a JavaScript interface  Renamed WebGLFloatArray  Renamed Float32Array  split into a backing ArrayBuffer and the typed Float32Array-view to access the buffer.  Types were added for other integer and floating-point sizes and signed/unsigned variants. 13
  • 14. Design considerations  Design of Typed Arrays  Need to efficiently pass binary data to native libraries.  The typed array views operate upon aligned data in the host CPU’s native endianness.  DataView  Designed for file and network I/O  The design split  in-memory data assembly (using the typed array views)  I/O (using DataView)  Modern JavaScript engines  Optimize the typed array views heavily  Achieve high performance on numerical operations 14
  • 15. References  [1] http://www.khronos.org/registry/typedarray/specs/latest/  [2] https://developer.mozilla.org/en/JavaScript_typed_arrays  [3] http://blogs.msdn.com/b/ie/archive/2011/12/01/working- with-binary-data-using-typed-arrays.aspx  [4] http://weblog.bocoup.com/javascript-typed-arrays/  [5] http://blog.n01se.net/?p=248  [6] http://ie.microsoft.com/testdrive/HTML5/TypedArrays/  [7] TYPED ARRAYS: BINARY DATA IN THE BROWSER, http://www.html5rocks.com/en/tutorials/webgl/typed_arrays/ 15