1 of 122

Project FuguReaching parity with native

Kenneth Christiansen @kennethrohde

Web Platform Architect, Intel

2 of 122

Hi! I am Kenneth

@kennethrohde

@kennethrohde

3 of 122

@kennethrohde

4 of 122

@kennethrohde

5 of 122

@kennethrohde

I the web!

6 of 122

@kennethrohde

The web is awesome

Great reach, low friction

safe

ephemeral

(deep) linkable

indexable

composable

7 of 122

@kennethrohde

8 of 122

@kennethrohde

9 of 122

@kennethrohde

10 of 122

The Web Platform is an amazing place to be

  • World wide reach
  • All major architectures, OS’s and form factors
  • Thriving open source ecosystem around it
  • Comprehensive APIs
  • Flexible, for apps, books, news, games etc
  • Performant execution

@kennethrohde

11 of 122

12 of 122

13 of 122

14 of 122

@kennethrohde

Audio & Video Capture

Advanced Camera Controls

Recording Media

Real-Time Communication

USB

Credentials

Payments

Network Type & Speed

Online State

Vibration

Battery Status

Local Notifications

Push Messages

Home Screen Installation

Foreground Detection

Permissions

File Reading

Touch Settings

Speech Recognition

Pointing Device Adaptation

Offline Mode

Background Sync

Geolocation

Device Position

Device Motion

Proximity Sensors

Virtual & Augmented Reality

Fullscreen

Screen Orientation & Lock

Wake Lock

Presentation Features

Virtual & Augmented Reality

Fullscreen

Screen Orientation & Lock

Presentation Features

Vibration

Device Memory

Bluetooth

Real-Time Communication

Touch Gestures

Storage Quotas

15 of 122

but sometimes you

need more power

@kennethrohde

16 of 122

We have Web Assembly!

@kennethrohde

17 of 122

wasm is a new portable, size- and load-time-efficient format suitable for compilation to the web

@kennethrohde

18 of 122

Kind of

an efficient, low-level bytecode

for the web

@kennethrohde

19 of 122

@kennethrohde

20 of 122

Web Assembly solves some real problems!

@kennethrohde

21 of 122

But we are still lacking some capabilities!

@kennethrohde

22 of 122

How do I work efficiently with local files?

@kennethrohde

23 of 122

@kennethrohde

24 of 122

@kennethrohde

25 of 122

@kennethrohde

Project Fugu

26 of 122

@kennethrohde

27 of 122

@kennethrohde

28 of 122

29 of 122

30 of 122

@kennethrohde

Delicious if prepared correctly, deadly if not

31 of 122

@kennethrohde

Enable web apps to do anything native apps can, �by exposing the capabilities of native platforms to the web platform, while maintaining user security, privacy, trust, and other core tenets of the web.

32 of 122

@kennethrohde

Enable web apps to do anything native apps can, �by exposing the capabilities of native platforms to �the web platform, while maintaining user security, privacy, trust, and other core tenets of the web.

33 of 122

bit.ly/powerful-apis

@kennethrohde

34 of 122

crbug.com?q=proj-fugu

@kennethrohde

35 of 122

The process

Traditionally it takes a long time to standardize web features

https://w3ctag.github.io/explainers.md

@kennethrohde

Write explainer

Solicit feedback and iterate

Formalize spec and look for public support

Origin Trial >> Ship It

Identify need and use-cases

36 of 122

Features being worked on

Closing the app gap

37 of 122

@kennethrohde

Hardware connectivity to USB and Bluetooth

Bluetooth Low Energy (BLE) is a wireless technology aimed at applications in healthcare, fitness, beacons, security, and toys.

USB is a wired general purpose technology

Accessing such devices shouldn’t requires downloading native apps.

Early efforts, started before Project Fugu

38 of 122

Use Cases

Connect to toys and use them from the web.

@kennethrohde

bluetooth.rocks/batmobile

Web�Bluetooth

39 of 122

Watch my earlier talk

on how to use Web Bluetooth and Web USB

@kennethrohde

Web USB and�Web Bluetooth

40 of 122

Web USB and

Web Bluetooth

Shipped!

@kennethrohde

Explainer

bit.ly/2YageJB

Updates Post

bit.ly/2vSAItp

bit.ly/31GmURd

Feedback

bit.ly/2ZOvJsd

Spec

bit.ly/2Y3G8hL

bit.ly/2N8aiyr

Demo

bit.ly/2J9TJQw

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

41 of 122

@kennethrohde

Accessing Serial and HID Devices

Bridge the physical world and the web by allowing web apps to communicate with devices such as microcontrollers, 3D printers, handheld barcode scanners and other peripheral devices.

42 of 122

Use Case

Connect to an Arduino or other microcontroller kit and program its microcontroller right from a web app.

@kennethrohde

Serial API

PhilippHenkel (https://commons.wikimedia.org/wiki/File:ArduinoUno.svg)

43 of 122

const requestOptions = {

// Filter on devices with the Arduino USB vendor ID.

filters: [{ vendorId: 0x2341 }],

};

// Request an Arduino from the user.

const port = await navigator.serial.requestPort(requestOptions);

// Open and begin reading.

await port.open({ baudrate: 115200 });

const reader = port.reader.getReader();

while (true) {

const {done, data} = await reader.read();

if (done) break;

console.log(data);

}

Proposed API

44 of 122

Serial API

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

bit.ly/2VcZRP5

Updates Post

Coming soon

Feedback

bit.ly/2JiSTAS

Spec

bit.ly/2GSId9B

Demo

Coming soon

45 of 122

Use Case

Logic for gamepads and other devices can be moved to JavaScript, providing more support than is possible from the browser.

@kennethrohde

WebHID

46 of 122

Use Case

The HID specification describes a wide array of devices that could be supported, including virtual reality controls, flight simulators, medical equipment, and more.

WebHID would allow these devices to be used without requiring additional drivers or modification to the browser.

@kennethrohde

WebHID

47 of 122

WebHID

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

bit.ly/2GY8inC

Updates Post

Coming soon

Discourse Thread

bit.ly/2H2Q5oT

Spec

bit.ly/2H4rzUe

Demo

Coming soon

48 of 122

@kennethrohde

Sharing Content and Receiving Shares

Sharing to other apps and receiving shares from other apps are core features of many experiences.

Sharing should just be universally supported, no matter if native or web.

49 of 122

Use Cases

The web should be able trigger shares to the system share sheet, making sharing super simple!

@kennethrohde

Web Share

50 of 122

if ('share' in navigator) {

const shareOpts = {

title: 'Unlocking New Capabilities for the Web',

text: 'One of the most exciting talks at I/O',

url: 'https://www.google.com',

}

navigator.share(shareOpts)

.then(() => {...})

.catch((e) => {...});

}

51 of 122

@kennethrohde

Receiving Shares

Native applications can act as share targets and receive content like text or files.

Web apps like social media sites should be able to register themselves as share targets to the system.

52 of 122

@kennethrohde

Receiving Shares

Native applications can act as share targets and receive content like text or files.

Web apps like social media sites should be able to register themselves as share targets to the system.

53 of 122

"share_target": {

"action": "/share-target/",

"method": "GET",

"enctype": "application/x-www-form-urlencoded",

"params": {

"title": "title",

"text": "text",

"url": "url"

}

}

Extends Web App Manifest

54 of 122

Web Share and Web Share Target

Shipped!

@kennethrohde

Explainer

bit.ly/2H0PuUF

Updates Post

bit.ly/2J4unUj

Discourse Thread

bit.ly/2H3uI6N

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

55 of 122

Web Share Target (v2)

In development

@kennethrohde

Explainer

bit.ly/2H0PuUF

Updates Post

Coming soon

Discourse Thread

Coming soon

Spec

bit.ly/2H0PVhL

Demo

Coming soon

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

56 of 122

Use Cases

Integrate your media with the device’s control panel to make the experience smooth.

@kennethrohde

Media Session �API

57 of 122

Use Cases

Control video playback in full screen mode.

Use your desktop media keys to control your media without the need to focus the tab where the media is playing.

Keyboard Media Buttons

58 of 122

navigator.mediaSession.setActionHandler('previoustrack', () => {

// User hit "Previous Track" key.

});

navigator.mediaSession.setActionHandler('nexttrack', () => {

// User hit "Next Track" key.

});

navigator.mediaSession.setActionHandler('play', () => {

// User hit "Play" key.

});

navigator.mediaSession.setActionHandler('pause', () => {

// User hit "Pause" key.

});

59 of 122

Media Session API

Shipped!

@kennethrohde

@kennethrohde

Explainer

bit.ly/2H1t4UM

Updates Post

bit.ly/2v1WMAz

Feedback

bit.ly/2Y8arUP

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

60 of 122

@kennethrohde

Detecting Barcodes �and Faces

A lot of things in the world have barcodes that you can scan with your phone camera, and when your camera detects a face, it will highlight it with a boundary box.

Web apps should be able to tap into our devices’ built-in detectors.

61 of 122

Use Cases

Scanning all sorts of barcodes �(QR codes, EAN-13 codes, Aztec codes, etc.) to identify products, make payments, and many more.

@kennethrohde

Shape Detection API

62 of 122

Use Cases

Scanning all sorts of barcodes �(QR codes, EAN-13 codes, Aztec codes, etc.) to identify products, make payments, and many more.

@kennethrohde

Shape Detection API

63 of 122

Use Cases

Scanning all sorts of barcodes �(QR codes, EAN-13 codes, Aztec codes, etc.) to identify products, make payments, and many more.

@kennethrohde

Shape Detection API

64 of 122

if ('FaceDetector' in window) {

const faces = await new FaceDetector().detect(img);

} else {

// Use fallback

}

if ('BarcodeDetector' in window) {

const codes = await new BarcodeDetector().detect(img);

} else {

// Use fallback

}

65 of 122

Shape Detection API

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

bit.ly/2JkrmPI

Updates Post

bit.ly/2Vl6ZJm

Discourse Thread

bit.ly/2H3uI6N

66 of 122

Use Cases

Subtly alert users of incoming events like a long-running task that has finished or an app’s state, like the number of unread messages.

@kennethrohde

Badging

Mock - demonstration purposes only.

67 of 122

// Setting a badge

window.Badge.set(42);

// Set the badge to a simple dot on the icon

window.Badge.set();

// Alternatively, explicitly clearing it

window.Badge.clear();

window.Badge.set(0);

68 of 122

Badging API

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

bit.ly/2Hejk8z

Updates Post

bit.ly/301m1CX

Discourse Thread

bit.ly/2H1drv4

69 of 122

@kennethrohde

Accessing the �users contacts

Native apps can easily ask for a access to a user’s contacts in their address book.

Web apps should be able to

70 of 122

Contacts Picker

Security Consideration

Give developers the features they need while ensuring users are in control of their own and their contacts’ information and understand what they share.

The contacts picker will only work when served from a secure host, and it can only be shown with a deliberate user gesture.

Users can also explicitly choose which contacts they want to share, and they see what is being shared before they share it.

@kennethrohde

71 of 122

const options = {

multiple: false,

properties: ['name', 'email', 'tel'],

};

try {

const contacts = await navigator.contacts.select(options);

// Do something with the contacts

} catch (e) {

// Handle error

}

Proposed API

72 of 122

[{

"email": ["kenneth.r.christiansen@intel.com"],

"name": ["Kenneth Christiansen"],

"tel": []

}]

Proposed API

73 of 122

Contacts Picker

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

bit.ly/2Jd34XV

Updates Post

Coming soon

Feedback

bit.ly/2J2VAaP

Spec

Coming soon

Demo

bit.ly/2Y5bbK6

74 of 122

Font Access API

Photo by Annie Spratt on Unsplash

Simplify use of locally installed logotype fonts, company standard fonts, or specially licensed fonts that are only available on the desktop.

75 of 122

Proposed API

const fonts = await navigator.fonts.query({local: true});

for (let font of fonts) {

console.log(font.family, font.postScriptName);

addFontToSelector(font);

}

76 of 122

Local Font Access

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

bit.ly/2H14rGn

Updates Post

Coming soon

Discourse Thread

bit.ly/2H3C3Dn

Spec

Coming soon

Demo

Coming soon

77 of 122

@kennethrohde

Reading and writing files

Web apps can open files and upload them to a server or work with them locally, but when you want to save, you have to download them and overwrite your local copy.

Web apps should be able to just read and write local files upon permission being granted.

78 of 122

Use Cases

Directly edit a file or multiple files without the need to upload and then download them.

@kennethrohde

File System

79 of 122

The File Picker

@kennethrohde

File System

80 of 122

Proposed API

const fileRef = await self.chooseFileSystemEntries(fileOpts);

// Read from the file

const file = await fileRef.getFile();

const image_data = await file.arrayBuffer();

// Write to the file

const writer = await fileRef.getWriter();

await writer.write(0, new_image_data);

81 of 122

File System

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

bit.ly/2Hek3GP

Updates Post

bit.ly/2LpvnVJ

Discourse Thread

bit.ly/2GZOz73

Spec

bit.ly/2H1titL

Demo

Coming soon

82 of 122

Project Fugu�Intel contributions

Kenneth Christiansen

Web Platform Architect, Intel

Rijubrata Bhaumik

Software Engineer, Intel

83 of 122

@kennethrohde

Generic Sensors

"The goal of the Generic Sensor API is to promote consistency across sensor APIs, enable advanced use cases thanks to performant low-level APIs, and increase the pace at which new sensors can be exposed to the Web by simplifying the specification and implementation processes."

84 of 122

The starting point: Existing APIs had various issues

@kennethrohde

  • Based on DOM events, inherits DOM event model limitations
  • Sensors not configurable, e.g. firing frequency not defined
  • Uses high-level concepts, introduces interoperability issues
  • No timestamps for readings, impossible to do proper sensor fusion
  • Difficult to extend and add new sensor types
  • Privacy & security issues and interoperability issues across browsers
  • Specification not maintained, known issues cannot be fixed

85 of 122

Implemented

    • Accelerometer
    • Gyroscope
    • LinearAccelerationSensor
    • AbsoluteOrientationSensor
    • RelativeOrientationSensor

Generic Sensor Extra Classes flag

    • AmbientLightSensor
    • Magnetometer

Implementation in Chrome

@kennethrohde

85

86 of 122

Grouping

@kennethrohde

Sensors are either low-level, derived or fusion (used data from multiple)

Sensor

Accelerometer

Gyroscope

Ambient Light

OrientationSensor

...

AbsoluteOrientationSensor

RelativeOrientationSensor

LinearAccelerationSensor

87 of 122

@kennethrohde

88 of 122

@kennethrohde

89 of 122

@kennethrohde

AmbientLightSensor is almost ready to ship

Works on Android as well as desktop, incl Windows/Edge

Use Cases:

https://w3c.github.io/ambient-light/#usecases-requirements

Privacy mitigations (Spec, Experiments)

  • Max sampling frequency (10 Hz)
  • Decreasing precision of sensor readouts to the nearest 50 Lux.

Close to ship ALS

90 of 122

@kennethrohde

91 of 122

Learn more

Generic Sensors presentation

bit.ly/generic-sensors

@kennethrohde

92 of 122

@kennethrohde

Near Field Comms

Read and write to NFC tags using the NFC data exchange format (NDEF)

93 of 122

  • Read and write NDEF records to NFC tags
  • Very complete NDEF support

Old NFC demo has been rewritten from scratch

https://kenchris.github.io/webnfc-groceries/

Screenshots:

https://photos.app.goo.gl/5K7WdjyiDDRxajNv6

Next steps

  • Follow up on UX privacy discussions
  • Origin Trial (M78) plan on track

@kennethrohde

93

Near Field Communication

94 of 122

Pretty cool, even

Sir Tim Berners-Lee is excited

@kennethrohde

95 of 122

@kennethrohde

Web NFC demo

96 of 122

Proposed API

const reader = new NFCReader();

reader.onreading = event => {

for (let record of event.message.records) {

// ...

}

};

const ctr = new AbortController;

reader.scan({ signal: ctr.signal });

97 of 122

Proposed API

const reader = new NFCReader();

reader.onreading = event => {

for (let record of event.message.records) {

if (record.recordType === "json") {

console.log(`JSON: ${record.toJSON().myProperty}`);

}

if (record.recordType === "opaque" && record.mediaType.startsWith('image/')) {

const blob = new Blob([record.toArrayBuffer()], {type: record.mediaType});

const img = document.createElement("img");

img.src = URL.createObjectURL(blob);

img.onload = () => window.URL.revokeObjectURL(this.src);

document.body.appendChild(img);

}

}

}

};

const ctr = new AbortController;

reader.scan({ signal: ctr.signal });

98 of 122

Proposed API

const writer = new NFCWriter();

writer.push({

records: [

{

recordType: "json",

mediaType: "application/json",

data: {

name: "Benny Jensen",

title: "Banker"

}

},

{

recordType: "json",

mediaType: "application/json",

data: {

name: "Zoey Braun",

title: "Engineer"

}

}]

}, {target: "tag", ignoreRead: false});

99 of 122

NFC

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Use-cases

bit.ly/2ZgD06M

Updates Post

Coming soon

Feedback

bit.ly/2VGqBHk

Spec

bit.ly/33AySh2

Demo

bit.ly/2ZdaNgO

100 of 122

@kennethrohde

Keeping an App Alive

Native apps can use wake locks to prevent a device from sleeping or to keep a device’s screen on.

Web apps should be able to do �the same.

101 of 122

102 of 122

Use Cases

Prevent a device from sleeping so a navigation app can get you from point A to point B and can notify you of turns you need to take.

Keep the screen of a device on while playing chess, so you can think about your next move as long as you want.

Wake Lock

103 of 122

@kennethrohde

Wake Lock

Two different kinds �of wake locks

A screen wake lock prevents the device’s screen from turning off so that the user can see the information that’s displayed on screen.

A system wake lock prevents the device’s CPU from entering standby mode so that your app can continue running.

104 of 122

@kennethrohde

Wake Lock

Keep a device awake

The Wake Lock API provides two types of wake locks: screen and system. One may imply the effects of the other. For example, a screen wake lock implies that the app—and therefore the system—should �continue running.

105 of 122

function tryKeepScreenAlive(minutes) {

navigator.wakeLock.request("screen").then(lock => {

setTimeout(() => lock.release(), minutes * 60 * 1000);

});

}

tryKeepScreenAlive(10);

106 of 122

Wake Lock

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

Coming soon

Updates Post

bit.ly/2IVyCCd

Feedback

bit.ly/2VGqBHk

107 of 122

Capture media

Be able to capture media from video feed as well as add filters etc

108 of 122

Media Capture extensions

  • Depth stream extensions
  • Pan/tilt/zoom control on compatible cameras
    • Useful for Enterprise VC

Mostly driven by my co-workers Alexandra Zhuravleva and Rijubrata Bhaunik who have also made a lot of demos

https://github.com/riju/WebCamera

109 of 122

@kennethrohde

Media Capture extensions

110 of 122

Media Stream Image Capture

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

111 of 122

Media Capture depth extensions

112 of 122

@kennethrohde

Media Capture depth extensions

113 of 122

@kennethrohde

Media Capture depth extensions

114 of 122

Media Capture Depth Stream Extensions

@kennethrohde

Identify �Need

Write �Explainer

Solicit �Feedback

Formalize �Spec

Ship�It

Explainer

Coming soon

Updates Post

Feedback

https://github.com/w3c/mediacapture-depth/

115 of 122

Audio & Video Capture

Advanced Camera Controls

Recording Media

Real-Time Communication

USB

Credentials

Payments

Network Type & Speed

Online State

Vibration

Battery Status

Local Notifications

Push Messages

Home Screen Installation

Foreground Detection

Permissions

File Reading

Touch Settings

Speech Recognition

Pointing Device Adaptation

Offline Mode

Background Sync

Geolocation

Device Position

Device Motion

Proximity Sensors

Virtual & Augmented Reality

Fullscreen

Screen Orientation & Lock

Wake Lock

Presentation Features

Virtual & Augmented Reality

Fullscreen

Screen Orientation & Lock

Presentation Features

Vibration

Device Memory

Bluetooth

Real-Time Communication

Touch Gestures

Storage Quotas

Existing

116 of 122

Audio & Video Capture

Advanced Camera Controls

Recording Media

Real-Time Communication

USB

Credentials

Payments

Network Type & Speed

Online State

Vibration

Battery Status

Local Notifications

Push Messages

Home Screen Installation

Foreground Detection

Permissions

File Reading

Contacts

SMS

Serial

Task Scheduling

Touch Settings

Speech Recognition

Pointing Device Adaptation

Offline Mode

Background Sync

Inter-App Communication

NFC

Geolocation

Geofencing

Device Position

Device Motion

Proximity Sensors

Virtual & Augmented Reality

Fullscreen

Screen Orientation & Lock

Wake Lock

Presentation Features

Wake Lock

Proximity Sensors

Ambient Light

Virtual & Augmented Reality

Fullscreen

Screen Orientation & Lock

Presentation Features

Task Scheduling

Vibration

Device Memory

Bluetooth

Real-Time Communication

Touch Gestures

Run on Startup

Clipboard Access

Unreliable Socket Communications

Storage Quotas

Clipboard Access

Unlimited Storage

WebHID (HID)

App Icon Badging

Local Fonts Access

2020

117 of 122

@kennethrohde

developers.chrome.com/origintrials

118 of 122

@kennethrohde

bit.ly/new-fugu-request

119 of 122

Tentative launches for in-flight APIs

M73

M72

M74

M75

M79

M76

M77

M78

Q1

Q2

Q3

Q4

Image Clipboard Support

Shape Detection

App Icon Badging

Wake Lock

Contacts Picker

Native File System Access

Phone Number Sign Up

Unlimited Quota

Scheduled Notifications

Web Serial / Web HID

Local Font Access

File Handling

M75

M76

M77

M78

M79

2019

OT

120 of 122

Updated plan from week 30

121 of 122

Resources

@kennethrohde

122 of 122

Thank you!

Thanks to Pete LePage and Thomas Steiner for allowing me to borrow some of their slides

@kennethrohde