SlideShare a Scribd company logo
Streams API
09/12/2015
youenn/calvaris
What is it?
• Enabling I/O processing
• Read chunks asynchronously
• Write chunks asynchronously
• Pipe from a stream to another
• Automatic transformations
• Any kind of chunk
• Strings
• ArrayBuffers
• Potatoes
• Any JSValue cocktail
What is it good for?
• Get me this video segment ASAP
• Without streams API: download it, then read it
• With the streams API + MSE: start downloading it and pipe it
to MSE
• Using SourceBuffer.appendStream
• Get me this WebSocket-like connection on HTTP
• ReadableStream/WritableStream to receive/send messages
• With HTTP/2, just one TCP/IP connection for both WebSocket-
like channels and regular HTTP content
• Any I/O use-case actually…
• Wrapping of all data sources in a single clean model
• HTTP, WebRTC, file system
What is in the spec?
• Stable
• ReadableStream
• Except pipe operations (related to WritableStream)
• Beta
• WritableStream
• Experimental
• TransformStream
• ReadableByteArrayStream
• May be almost merged with ReadableStream
What it is good for/bad for,
internals?
• Promise based
• Async is good but
• Still a bit expensive
• Use it for arrays, objects
• Probably not to pass one byte after one byte
Where will it be?
• Fetch API
• Retrieve data progressively
• Send data progressively
• MSE API
• Append stream
• WebRTC
• Plan to use it
ReadableStream API remarks
• ReadableStream : locked, cancel, getReader,
pipeThrough, pipeTo, tee.
• Underlying source : start, pull, cancel.
• Strategy : highWaterMark, size
• Controller: enqueue, close, error, desiredSize
• Reader : closed, cancel, read and releaseLock
How is it working?
httpResponseBody.pipeThrough(decom pressorTransform )
.pipeThrough(ignoreNonIm ageFilesTransform )
.pipeTo(m ediaG allery);
Where is it?
• Chrome
• Shipped
• ReadableStream tied to the Fetch API response
• Ongoing
• ReadableStream created by scripts
• ReadableStream for progressive uploads using fetch
• Mozilla
• Will start 25/12/2015 (roughly)
• IE
• Support of an earlier version of stream/XHR as producer
• WebKit
• ReadableStream fully implemented
• pipeTo to be broken by the spec
• WritableStream fully implemented
Implementation Story
First Approach – Initial steps
• C++ implementation
• Regular WebIDL to bind API with JavaScriptCore
• Needed improved promise binding code
• Initial prototype supporting byte arrays
• Nicely working
• Not too complex
First Approach – second steps
• Support of any JavaScript value
• WebIDL
• Starting to add special cases in the binding generator
• Adding a lot of JS code in WebCore/bindings/js
• Storing JS values, making them not collectable
• Calling JS functions
• Handling of asynchronous behavior, JS promises
• Overall conclusion
• Code difficult to relate with the specification
• Difficult to keep proper reference counting
• Templates to add further specialization for byte array
Second Approach – JS Builtins
• JS Builtin is a JavaScriptCore feature
• Introduced a few years ago
• Promise code is mostly JS builtin
• Enable JS Builtin into WebCore
• Integrate it with WebIDL binding generator
• Streams API implementation
• WebIDL code
• JavaScript code
• Some limited C++ code
• 80 lines
• Except for automatically generated code
JS Builtins tied to WebIDL
• WebIDL
• JavaScript built-in
JS Builtins calling C++ methods
• Private keyword
JS Builtins misc
• Conditional compilation
• @conditional
• Constructor as JS built-in
• @assert
• JS built-in functions (helper routines) attached to the
global object
• @internal
JS Builtins build
• Update CMakeLists.txt
• Add IDL file in WebCore_NON_SVG_IDL_FILES
• Add JS file(s) in WebCore_BUILTINS_SOURCES
• 1 file for WebIDL tied routines (stored in the prototype)
• 0/1/+ files for helper routines (stored in the global object)
• Update Source/WebCore/bindings/js/WebCoreBuiltins.h
and Source/WebCore/bindings/js/WebCoreBuiltins.cpp
• When adding a new JS built-in file
• To be automated soon hopefully
Overall experience
• Easier to write JS code then to write C++ binding code
• No more crashes, no more memory leaks, no more ref-
counting cycles
• Performances is not really an issue
• Apple made measurements on the Promise implementation
and saw some improvements
• Everything is nice, except…
• No JS built-in code debugger
• Back to console.log(“potato 1”);
• JS builtin security issues
Security issues
• JS builtins run in the same world with the same
GlobalObject as user scripts
• Modifying a prototype or a user object may affect JS built-in
code
• First possibility: JS built-in code may break
• What if mediaDevices is overridden by user scripts?
• What if mediaDevices prototype is changed.
Security issues – leaking information
Security issues – current rules
• Do not use functions under the control of the user
operations.push(…)
operations.@push(...)
• Do not use prototype of objects under the control of the user
function processValue(promise) {
promise.then(…)
}
function processValue(promise) {
promise.@then(…) // ok but it may break
}
function processValue(promise) {
@Promise.prototype. @then.@call(…) // ok but so unreadable
}
• Beware of Promise
• Might want to use InternalPromise if you are doing chaining
Security issues – we need something
better
• So easy to fall into that trap
• Not so easy to find the holes
• How can we improve the situation?
• Testing tool to catch these errors
• JS builtin check style?
• JS proxy object in Debug mode to control how are accessed objects
• Sanitizers
• Should we change the infrastructure?
• Run the built-ins in a more secure environment
• Chrome is doing that in a completely separate world
• Cannot pass promises, JS objects.... Between the worlds
• Input most welcome
Tentative conclusion
• Streams API is
• Very maintainable
• Fast enough (more study needed)
• But
• Potential security issues
• We fixed the ones we know of
• Need to improve JS built-in tooling
• Think about JS built-ins when adding WebCore/JSC
specific code
• Like in WebCore/bindings/js

More Related Content

What's hot (20)

PPTX
OpenNebula in a Multiuser Environment
NETWAYS
 
PDF
Introduction of eBPF - 時下最夯的Linux Technology
Jace Liang
 
PDF
The Beam Vision for Portability: "Write once run anywhere"
Knoldus Inc.
 
PPTX
Kubernetes CRI containerd integration by Lantao Liu (Google)
Docker, Inc.
 
PDF
End-to-End Reactive Data Access Using R2DBC with RSocket and Proteus
VMware Tanzu
 
PDF
gRPC: The Story of Microservices at Square
Apigee | Google Cloud
 
PDF
Angular v2 et plus : le futur du développement d'applications en entreprise
LINAGORA
 
PDF
2017 Microservices Practitioner Virtual Summit: The Mechanics of Deploying En...
Ambassador Labs
 
PPTX
Breaking down a monolith
GeekNightHyderabad
 
PDF
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...
Srijan Technologies
 
PDF
Netty @Apple: Large Scale Deployment/Connectivity
C4Media
 
PDF
REST in Peace. Long live gRPC!
QAware GmbH
 
PDF
CRI, OCI, and CRI-O
Che-Chia Chang
 
PDF
Leveraging the Power of containerd Events - Evan Hazlett
Docker, Inc.
 
PDF
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
tdc-globalcode
 
PDF
[Draft] Fast Prototyping with DPDK and eBPF in Containernet
Andrew Wang
 
PDF
Vincit Teatime 2015.2 - Niko Kurtti: SaaSiin pa(i)nostusta
VincitOy
 
PDF
KubeCon EU 2016: "rktnetes": what's new with container runtimes and Kubernetes
KubeAcademy
 
PDF
K8s storage-glusterfs-20180210
Che-Chia Chang
 
ODP
Oslo Vancouver Project Update
Ben Nemec
 
OpenNebula in a Multiuser Environment
NETWAYS
 
Introduction of eBPF - 時下最夯的Linux Technology
Jace Liang
 
The Beam Vision for Portability: "Write once run anywhere"
Knoldus Inc.
 
Kubernetes CRI containerd integration by Lantao Liu (Google)
Docker, Inc.
 
End-to-End Reactive Data Access Using R2DBC with RSocket and Proteus
VMware Tanzu
 
gRPC: The Story of Microservices at Square
Apigee | Google Cloud
 
Angular v2 et plus : le futur du développement d'applications en entreprise
LINAGORA
 
2017 Microservices Practitioner Virtual Summit: The Mechanics of Deploying En...
Ambassador Labs
 
Breaking down a monolith
GeekNightHyderabad
 
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...
Srijan Technologies
 
Netty @Apple: Large Scale Deployment/Connectivity
C4Media
 
REST in Peace. Long live gRPC!
QAware GmbH
 
CRI, OCI, and CRI-O
Che-Chia Chang
 
Leveraging the Power of containerd Events - Evan Hazlett
Docker, Inc.
 
TDC2017 | São Paulo - Trilha Containers How we figured out we had a SRE team ...
tdc-globalcode
 
[Draft] Fast Prototyping with DPDK and eBPF in Containernet
Andrew Wang
 
Vincit Teatime 2015.2 - Niko Kurtti: SaaSiin pa(i)nostusta
VincitOy
 
KubeCon EU 2016: "rktnetes": what's new with container runtimes and Kubernetes
KubeAcademy
 
K8s storage-glusterfs-20180210
Che-Chia Chang
 
Oslo Vancouver Project Update
Ben Nemec
 

Viewers also liked (20)

PPSX
Active International
MikeChar Villeneuve
 
PPTX
Releasing the People's Data
Open Data @ CTIC
 
PPT
Akirachix Engaging Women
Web Gathering
 
PPTX
Week 5 Whats The Big Idea - Emma Dicks
UCT Upstarts
 
PPT
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...
OpenAIRE
 
PPTX
Chapter 1
Muhammad Said Hasibuan
 
PPTX
Quasar - Credentials
sumitgandhiquasar
 
PDF
In just five years 2011
VeracityMedia
 
PPTX
DCU School of Physical Sciences
Dublin City University
 
PDF
Euskal Valley v9
On4U Global Services
 
PDF
Разработка под iPhone для начинающих
tabtabus
 
PDF
Rendezvény Navigátor Magazin Május
Megszervezem.hu csapat
 
PDF
MMD_Vision 2015
Andrew Bulmer
 
PDF
Regional Newsletter (Winter 2014/15)
ENPI FLEG
 
PDF
OCRFeeder (FOSDEM 2010)
Igalia
 
PDF
InnovAction Lab 2015 - New Editions
Codemotion
 
PPT
Combining archetypes with FHIR in future-proof health information systems
yampeku
 
PDF
Creative Business Cup Competition Manual
Startupi
 
PDF
Social Change Through Innovation as part of "Social Enterprise as an Agent of...
Juan Sebastian Vasquez
 
PDF
Tut21-115-GauravKishore-FDS-Final
Bolt Zhang
 
Active International
MikeChar Villeneuve
 
Releasing the People's Data
Open Data @ CTIC
 
Akirachix Engaging Women
Web Gathering
 
Week 5 Whats The Big Idea - Emma Dicks
UCT Upstarts
 
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...
OpenAIRE
 
Quasar - Credentials
sumitgandhiquasar
 
In just five years 2011
VeracityMedia
 
DCU School of Physical Sciences
Dublin City University
 
Euskal Valley v9
On4U Global Services
 
Разработка под iPhone для начинающих
tabtabus
 
Rendezvény Navigátor Magazin Május
Megszervezem.hu csapat
 
MMD_Vision 2015
Andrew Bulmer
 
Regional Newsletter (Winter 2014/15)
ENPI FLEG
 
OCRFeeder (FOSDEM 2010)
Igalia
 
InnovAction Lab 2015 - New Editions
Codemotion
 
Combining archetypes with FHIR in future-proof health information systems
yampeku
 
Creative Business Cup Competition Manual
Startupi
 
Social Change Through Innovation as part of "Social Enterprise as an Agent of...
Juan Sebastian Vasquez
 
Tut21-115-GauravKishore-FDS-Final
Bolt Zhang
 

Similar to Streams API (Web Engines Hackfest 2015) (20)

PDF
Streams
Eugene Lazutkin
 
PDF
Matthew Eernisse, NodeJs, .toster {webdev}
.toster
 
PDF
Building Killer RESTful APIs with NodeJs
Srdjan Strbanovic
 
KEY
NodeJS
.toster
 
PPTX
Web streams
Vladimir Shevchuk
 
PDF
NodeJS
LinkMe Srl
 
PPTX
StrongLoop Overview
Shubhra Kar
 
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
PDF
APIs, now and in the future
Chris Mills
 
PPTX
NodeJS
Alok Guha
 
PDF
More efficient, usable web
Chris Mills
 
KEY
Mongo and node mongo dc 2011
async_io
 
PDF
Node.js streams talk
zladuric
 
PPT
The future of server side JavaScript
Oleg Podsechin
 
PDF
Nodejs - Should Ruby Developers Care?
Felix Geisendörfer
 
KEY
node.js: Javascript's in your backend
David Padbury
 
ODP
Javascript Update May 2013
RameshNair6
 
KEY
Let's run JavaScript Everywhere
Tom Croucher
 
PPTX
HTML5 Programming
hotrannam
 
PPTX
Next-generation JavaScript - OpenSlava 2014
Oscar Renalias
 
Matthew Eernisse, NodeJs, .toster {webdev}
.toster
 
Building Killer RESTful APIs with NodeJs
Srdjan Strbanovic
 
NodeJS
.toster
 
Web streams
Vladimir Shevchuk
 
NodeJS
LinkMe Srl
 
StrongLoop Overview
Shubhra Kar
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
APIs, now and in the future
Chris Mills
 
NodeJS
Alok Guha
 
More efficient, usable web
Chris Mills
 
Mongo and node mongo dc 2011
async_io
 
Node.js streams talk
zladuric
 
The future of server side JavaScript
Oleg Podsechin
 
Nodejs - Should Ruby Developers Care?
Felix Geisendörfer
 
node.js: Javascript's in your backend
David Padbury
 
Javascript Update May 2013
RameshNair6
 
Let's run JavaScript Everywhere
Tom Croucher
 
HTML5 Programming
hotrannam
 
Next-generation JavaScript - OpenSlava 2014
Oscar Renalias
 

More from Igalia (20)

PDF
Life of a Kernel Bug Fix
Igalia
 
PDF
Unlocking the Full Potential of WPE to Build a Successful Embedded Product
Igalia
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PDF
Jumping Over the Garden Wall - WPE WebKit on Android
Igalia
 
PDF
Collective Funding, Governance and Prioritiation of Browser Engine Projects
Igalia
 
PDF
Don't let your motivation go, save time with kworkflow
Igalia
 
PDF
Solving the world’s (localization) problems
Igalia
 
PDF
The Whippet Embeddable Garbage Collection Library
Igalia
 
PDF
Nobody asks "How is JavaScript?"
Igalia
 
PDF
Getting more juice out from your Raspberry Pi GPU
Igalia
 
PDF
WebRTC support in WebKitGTK and WPEWebKit with GStreamer: Status update
Igalia
 
PDF
Demystifying Temporal: A Deep Dive into JavaScript New Temporal API
Igalia
 
PDF
CSS :has() Unlimited Power
Igalia
 
PDF
Device-Generated Commands in Vulkan
Igalia
 
PDF
Current state of Lavapipe: Mesa's software renderer for Vulkan
Igalia
 
PDF
Vulkan Video is Open: Application showcase
Igalia
 
PDF
Scheme on WebAssembly: It is happening!
Igalia
 
PDF
EBC - A new backend compiler for etnaviv
Igalia
 
PDF
RISC-V LLVM State of the Union
Igalia
 
PDF
Device-Generated Commands in Vulkan
Igalia
 
Life of a Kernel Bug Fix
Igalia
 
Unlocking the Full Potential of WPE to Build a Successful Embedded Product
Igalia
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
Jumping Over the Garden Wall - WPE WebKit on Android
Igalia
 
Collective Funding, Governance and Prioritiation of Browser Engine Projects
Igalia
 
Don't let your motivation go, save time with kworkflow
Igalia
 
Solving the world’s (localization) problems
Igalia
 
The Whippet Embeddable Garbage Collection Library
Igalia
 
Nobody asks "How is JavaScript?"
Igalia
 
Getting more juice out from your Raspberry Pi GPU
Igalia
 
WebRTC support in WebKitGTK and WPEWebKit with GStreamer: Status update
Igalia
 
Demystifying Temporal: A Deep Dive into JavaScript New Temporal API
Igalia
 
CSS :has() Unlimited Power
Igalia
 
Device-Generated Commands in Vulkan
Igalia
 
Current state of Lavapipe: Mesa's software renderer for Vulkan
Igalia
 
Vulkan Video is Open: Application showcase
Igalia
 
Scheme on WebAssembly: It is happening!
Igalia
 
EBC - A new backend compiler for etnaviv
Igalia
 
RISC-V LLVM State of the Union
Igalia
 
Device-Generated Commands in Vulkan
Igalia
 

Recently uploaded (20)

PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 

Streams API (Web Engines Hackfest 2015)

  • 2. What is it? • Enabling I/O processing • Read chunks asynchronously • Write chunks asynchronously • Pipe from a stream to another • Automatic transformations • Any kind of chunk • Strings • ArrayBuffers • Potatoes • Any JSValue cocktail
  • 3. What is it good for? • Get me this video segment ASAP • Without streams API: download it, then read it • With the streams API + MSE: start downloading it and pipe it to MSE • Using SourceBuffer.appendStream • Get me this WebSocket-like connection on HTTP • ReadableStream/WritableStream to receive/send messages • With HTTP/2, just one TCP/IP connection for both WebSocket- like channels and regular HTTP content • Any I/O use-case actually… • Wrapping of all data sources in a single clean model • HTTP, WebRTC, file system
  • 4. What is in the spec? • Stable • ReadableStream • Except pipe operations (related to WritableStream) • Beta • WritableStream • Experimental • TransformStream • ReadableByteArrayStream • May be almost merged with ReadableStream
  • 5. What it is good for/bad for, internals? • Promise based • Async is good but • Still a bit expensive • Use it for arrays, objects • Probably not to pass one byte after one byte
  • 6. Where will it be? • Fetch API • Retrieve data progressively • Send data progressively • MSE API • Append stream • WebRTC • Plan to use it
  • 7. ReadableStream API remarks • ReadableStream : locked, cancel, getReader, pipeThrough, pipeTo, tee. • Underlying source : start, pull, cancel. • Strategy : highWaterMark, size • Controller: enqueue, close, error, desiredSize • Reader : closed, cancel, read and releaseLock
  • 8. How is it working? httpResponseBody.pipeThrough(decom pressorTransform ) .pipeThrough(ignoreNonIm ageFilesTransform ) .pipeTo(m ediaG allery);
  • 9. Where is it? • Chrome • Shipped • ReadableStream tied to the Fetch API response • Ongoing • ReadableStream created by scripts • ReadableStream for progressive uploads using fetch • Mozilla • Will start 25/12/2015 (roughly) • IE • Support of an earlier version of stream/XHR as producer • WebKit • ReadableStream fully implemented • pipeTo to be broken by the spec • WritableStream fully implemented
  • 11. First Approach – Initial steps • C++ implementation • Regular WebIDL to bind API with JavaScriptCore • Needed improved promise binding code • Initial prototype supporting byte arrays • Nicely working • Not too complex
  • 12. First Approach – second steps • Support of any JavaScript value • WebIDL • Starting to add special cases in the binding generator • Adding a lot of JS code in WebCore/bindings/js • Storing JS values, making them not collectable • Calling JS functions • Handling of asynchronous behavior, JS promises • Overall conclusion • Code difficult to relate with the specification • Difficult to keep proper reference counting • Templates to add further specialization for byte array
  • 13. Second Approach – JS Builtins • JS Builtin is a JavaScriptCore feature • Introduced a few years ago • Promise code is mostly JS builtin • Enable JS Builtin into WebCore • Integrate it with WebIDL binding generator • Streams API implementation • WebIDL code • JavaScript code • Some limited C++ code • 80 lines • Except for automatically generated code
  • 14. JS Builtins tied to WebIDL • WebIDL • JavaScript built-in
  • 15. JS Builtins calling C++ methods • Private keyword
  • 16. JS Builtins misc • Conditional compilation • @conditional • Constructor as JS built-in • @assert • JS built-in functions (helper routines) attached to the global object • @internal
  • 17. JS Builtins build • Update CMakeLists.txt • Add IDL file in WebCore_NON_SVG_IDL_FILES • Add JS file(s) in WebCore_BUILTINS_SOURCES • 1 file for WebIDL tied routines (stored in the prototype) • 0/1/+ files for helper routines (stored in the global object) • Update Source/WebCore/bindings/js/WebCoreBuiltins.h and Source/WebCore/bindings/js/WebCoreBuiltins.cpp • When adding a new JS built-in file • To be automated soon hopefully
  • 18. Overall experience • Easier to write JS code then to write C++ binding code • No more crashes, no more memory leaks, no more ref- counting cycles • Performances is not really an issue • Apple made measurements on the Promise implementation and saw some improvements • Everything is nice, except… • No JS built-in code debugger • Back to console.log(“potato 1”); • JS builtin security issues
  • 19. Security issues • JS builtins run in the same world with the same GlobalObject as user scripts • Modifying a prototype or a user object may affect JS built-in code • First possibility: JS built-in code may break • What if mediaDevices is overridden by user scripts? • What if mediaDevices prototype is changed.
  • 20. Security issues – leaking information
  • 21. Security issues – current rules • Do not use functions under the control of the user operations.push(…) operations.@push(...) • Do not use prototype of objects under the control of the user function processValue(promise) { promise.then(…) } function processValue(promise) { promise.@then(…) // ok but it may break } function processValue(promise) { @Promise.prototype. @then.@call(…) // ok but so unreadable } • Beware of Promise • Might want to use InternalPromise if you are doing chaining
  • 22. Security issues – we need something better • So easy to fall into that trap • Not so easy to find the holes • How can we improve the situation? • Testing tool to catch these errors • JS builtin check style? • JS proxy object in Debug mode to control how are accessed objects • Sanitizers • Should we change the infrastructure? • Run the built-ins in a more secure environment • Chrome is doing that in a completely separate world • Cannot pass promises, JS objects.... Between the worlds • Input most welcome
  • 23. Tentative conclusion • Streams API is • Very maintainable • Fast enough (more study needed) • But • Potential security issues • We fixed the ones we know of • Need to improve JS built-in tooling • Think about JS built-ins when adding WebCore/JSC specific code • Like in WebCore/bindings/js