Weird Browsers

A presentation at Frontend NE in March 2016 in Newcastle upon Tyne, UK by Niels Leenheer

Slide 1

Slide 1

?weird browsers? frontend ne — march 3rd 2016 @html5test

Slide 2

Slide 2

Slide 3

Slide 3

Slide 4

Slide 4

458 Edge 13 400 521 Safari 9 Chrome 48 0 555 478 Firefox 44 desktop browsers results on html5test.com

Slide 5

Slide 5

458 Edge 13 400 521 Safari 9 Chrome 48 0 555 478 Firefox 44 desktop browsers results on html5test.com

Slide 6

Slide 6

402 Edge 12 458 Edge 13 400 521 Safari 9 Chrome 48 0 555 16 336 478 Internet Explorer 6 Internet Explorer 11 Firefox 44 desktop browsers results on html5test.com

Slide 7

Slide 7

Slide 8

Slide 8

?weird browsers?

Slide 9

Slide 9

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

Slide 14

Slide 14

Slide 15

Slide 15

Slide 16

Slide 16

Slide 17

Slide 17

Slide 18

Slide 18

Slide 19

Slide 19

Slide 20

Slide 20

Slide 21

Slide 21

Slide 22

Slide 22

Slide 23

Slide 23

?weird browsers?

Slide 24

Slide 24

?weird browsers?

Slide 25

Slide 25

game consoles

Slide 26

Slide 26

portable game consoles

Slide 27

Slide 27

smart tvs

Slide 28

Slide 28

e-readers

Slide 29

Slide 29

smartwatches

Slide 30

Slide 30

photo cameras

Slide 31

Slide 31

Andre Jay Meissner cars

Slide 32

Slide 32

Slide 33

Slide 33

smart tvs, set-top boxes and consoles

Slide 34

Slide 34

“big screen browsers”

Slide 35

Slide 35

Slide 36

Slide 36

television browsers are pretty good the last generation of television sets use operating systems that originate from mobile

Slide 37

Slide 37

281 Google TV 418 LG WebOS 414 238 Panasonic Firefox OS LG Netcast 0 555 301 407 Panasonic Samsung Viera 2014 465 Samsung Tizen 449 Opera Devices smart tv results on html5test.com

Slide 38

Slide 38

53 309 Playstation 3 Playstation TV 98 328 Xbox 360 Playstation 4 286 Xbox One 0 555 66 311 Wii Wii U console results on html5test.com

Slide 39

Slide 39

53 309 Playstation 3 Playstation TV 98 328 Xbox 360 Playstation 4 286 Xbox One 0 555 66 311 426 Wii Wii U Xbox One with Edge console results on html5test.com

Slide 40

Slide 40

Slide 41

Slide 41

1 control

Slide 42

Slide 42

the biggest challenge of of television browsers

Slide 43

Slide 43

navigation (without mouse or touchscreen)

Slide 44

Slide 44

d-pad

Slide 45

Slide 45

navigation with the d-pad

Slide 46

Slide 46

but it can be worse: moving the cursor with the arrow keys

Slide 47

Slide 47

alternatives

Slide 48

Slide 48

analog controllers

Slide 49

Slide 49

remotes with trackpad

Slide 50

Slide 50

remotes with airmouse

Slide 51

Slide 51

second screen

Slide 52

Slide 52

many manufacturers also create apps for controlling the smart tv, console or set-top box

Slide 53

Slide 53

Slide 54

Slide 54

Slide 55

Slide 55

text input (without keyboard)

Slide 56

Slide 56

d-pads

Slide 57

Slide 57

text input with the d-pad

Slide 58

Slide 58

alternatives

Slide 59

Slide 59

remotes with keyboards

Slide 60

Slide 60

wireless keyboards

Slide 61

Slide 61

and apps

Slide 62

Slide 62

Slide 63

Slide 63

gesture control (throw your hands up in the air, and wave ’em like you just don’t care)

Slide 64

Slide 64

navigation with gesture control

Slide 65

Slide 65

can we control these input methods directly from javascript?

Slide 66

Slide 66

the d-pad maybe

Slide 67

Slide 67

1 keyboard events window.addEventListener("keypress", function(e) { e.preventDefault(); // no navigation ... });

Slide 68

Slide 68

the gamepad maybe

Slide 69

Slide 69

1 the gamepad api var gamepads = navigator.getGamepads(); for (var i = 0; i < gamepads.length; i++) { ... }

Slide 70

Slide 70

2 wii u api window.setInterval(function() { var state = window.wiiu.gamepad.update(); ... }, 100);

Slide 71

Slide 71

the webcam maybe

Slide 72

Slide 72

1 the getusermedia api navigator.getUserMedia( { audio: true, video: { width: 1280, height: 720 } }, function(stream) { ... }, function(error) { ... } );

Slide 73

Slide 73

2 the difference between a television and a monitor

Slide 74

Slide 74

overscan (let’s make it a bit more complicated)

Slide 75

Slide 75

due to historical reasons televisions will not show the borders of the image

Slide 76

Slide 76

1920 pixels the television enlarges all images from the hdmi input by 5%

Slide 77

Slide 77

1920 pixels the television enlarges all images from the hdmi input by 5%

Slide 78

Slide 78

the image is then cropped to 1920 by 1080 pixels

Slide 79

Slide 79

the image is then cropped to 1920 by 1080 pixels

Slide 80

Slide 80

overscan causes blurry output +5%

Slide 81

Slide 81

solution 1 overscan correction

Slide 82

Slide 82

1920 pixels the browser does not use the edges of the image

Slide 83

Slide 83

1920 pixels the television will enlarge the image by 5%

Slide 84

Slide 84

and the content is now fully visible, the unused border is cropped out of the final image

Slide 85

Slide 85

but not every television set enlarges the image by exactly 5%, this can vary between manufacturers and models

Slide 86

Slide 86

configure the correct overscan correction in the system preferences

Slide 87

Slide 87

the playstation 4 will always show the browser without overscan correction in full screen mode

Slide 88

Slide 88

the playstation 4 will always show the browser without overscan correction in full screen mode

Slide 89

Slide 89

solution 2 no overscan

Slide 90

Slide 90

it is possible to disable overscan on many television sets ‘screen fit’, ‘pixel perfect’ or ‘just scan’

Slide 91

Slide 91

the playstation 3 always shows the browser with overscan correction

Slide 92

Slide 92

the viewport (i really need some aspirin!)

Slide 93

Slide 93

the visual viewport the visual viewport determines which part of the website will be visible measured in device pixels

Slide 94

Slide 94

the visual viewport the visual viewport determines which part of the website will be visible measured in device pixels

Slide 95

Slide 95

the visual viewport the visual viewport determines which part of the website will be visible measured in device pixels

Slide 96

Slide 96

the layout viewport the layout viewport determines the width in css pixels on which the site will be rendered

Slide 97

Slide 97

the layout viewport the layout viewport determines the width in css pixels on which the site will be rendered

Slide 98

Slide 98

the layout viewport the layout viewport determines the width in css pixels on which the site will be rendered

Slide 99

Slide 99

the default layout viewport is different on every smart tv, console or set-top box between 800 and 1920 css pixels

Slide 100

Slide 100

it is possible to change the width of the layout viewport with the ‘meta viewport’ tag physical device pixels device scale factor

<meta name="viewport" content=“width=device-width"> <meta name="viewport" content="width=1024">

Slide 101

Slide 101

complication: meta viewport is not supported it is not possible to get the same layout viewport width in all of the different browsers

Slide 102

Slide 102

complication: device pixel ratio is not supported there is no proper way to show images with the same resolution as the physical screen

Slide 103

Slide 103

800 pixels nintendo wii

Slide 104

Slide 104

980 pixels nintendo wii u

Slide 105

Slide 105

960 pixels lg webos

Slide 106

Slide 106

1041 of 1050 pixels microsoft xbox 360

Slide 107

Slide 107

1200 of 1236 pixels microsoft xbox one

Slide 108

Slide 108

1824 pixels sony playstation 3

Slide 109

Slide 109

1920 pixels sony playstation 4

Slide 110

Slide 110

Nintendo Wii 800 LG WebOS 960 Nintendo Wii U 980 Philips 2014 series 980 Google TV 1024 Playstation TV 1024 Samsung Tizen 1024 Xbox 360 1051 Xbox One 1200 LG Netcast 1226 Panasonic Viera 1256 Opera Devices 1280 Samsung 2014 series 1280 Panasonic Firefox OS 1536 Playstation 3 1824 Playstation 4 1920

Slide 111

Slide 111

device pixels != device pixels (of course not)

Slide 112

Slide 112

sometimes devices pixels are not physical devices pixels, but virtual device pixels the browser renders in a lower resolution which is upscaled to the resolution of the display

Slide 113

Slide 113

3 distance to the screen

Slide 114

Slide 114

20 inch

Slide 115

Slide 115

20 inch

Slide 116

Slide 116

10 foot

Slide 117

Slide 117

“Make fonts and graphics on the site larger to account for viewing distance. People sit proportionally farther from a TV than from a computer monitor of the same size.” – Internet Explorer for Xbox One Developer Guide https://msdn.microsoft.com/en-us/library/dn532261(v=vs.85).aspx

Slide 118

Slide 118

Make your text and images two to three times bigger

Slide 119

Slide 119

Make your text and images two to three times bigger

Slide 120

Slide 120

Make your text and images two to three times bigger

Slide 121

Slide 121

youtube tv website

Slide 122

Slide 122

responsive design the size of the contents is determined by the width of the viewport

Slide 123

Slide 123

1 use percentages for positioning .left { width: 60%; } .right { left: 60%; width: 40%; }

Slide 124

Slide 124

2 base the fontsize on the viewport document.body.style.fontSize = ((window.innerWidth / 1920) * 300) + '%';

Slide 125

Slide 125

3 or maybe use viewport units – with polyfill body { font-size: 3vw; } .left { width: 60vw; height: 100vh; } .right { width: 40vw; height: 100vh; }

Slide 126

Slide 126

4 use a safe margin around the contents body { padding: 5%; }

Slide 127

Slide 127

identifying smart tv’s (css for televisions)

Slide 128

Slide 128

1 × css media types @media tv { body { font-size: 300%; } }

Slide 129

Slide 129

1 css media types all television browsers use the css media type ‘screen’

Slide 130

Slide 130

2 × screen size if (screen.width == 1920 && screen.height == 1080) { document.body.className += " television"; }

Slide 131

Slide 131

2 screen size monitors and phones often use hd resolutions, television browsers often use other resolutions

Slide 132

Slide 132

3 × useragent sniffing if (navigator.userAgent.search(/TV/i) >= 0) { document.body.className += " television"; }

Slide 133

Slide 133

3 useragent sniffing not all smart tv’s are recognisable Mozilla/5.0 (X11; Linux; ko-KR) AppleWebKit/534.26+ (KHTML, like Gecko) Version/5.0 Safari/534.26+

Slide 134

Slide 134

4 couch mode the only reliable way to optimise a website for television is to make two different websites… or give the user the ability to switch on couch mode

Slide 135

Slide 135

4 be careful with feature detection

Slide 136

Slide 136

“Basically every feature that talks to the operating system or hardware, is suspect.” – Me http://blog.html5test.com/2015/08/the-problems-with-feature-detection/

Slide 137

Slide 137

if (!!navigator.geolocation) { navigator.geolocation.getCurrentPosition( success, failure ); } else { // alternative }

Slide 138

Slide 138

if (!!navigator.geolocation) { navigator.geolocation.getCurrentPosition( success, failure ); } 1 failure is called with a “permission denied” error code 2 no callback at all to success or failure

Slide 139

Slide 139

if (!!navigator.geolocation) { navigator.geolocation.getCurrentPosition( success, failure ); } 3 success is called with longitude = 0 and latitude = 0 4 success is called with the coordinates of Mountain View, USA

Slide 140

Slide 140

is there a future for web apps on the big screen?

Slide 141

Slide 141

Slide 142

Slide 142

the new apple tv does not ship with a browser by default

Slide 143

Slide 143

android tv does not ship with a browser by default

Slide 144

Slide 144

Slide 145

Slide 145

e-readers

Slide 146

Slide 146

187 280 Kindle Touch Kobo 157 Sony Reader 0 555 52 196 Kindle 3 Pocketbook e-reader results on html5test.com

Slide 147

Slide 147

infrared touch screen

Slide 148

Slide 148

led’s sensors

Slide 149

Slide 149

mouse events down/up move amazon kindle touch yes pocketbook basic touch yes kobo glow yes yes sony reader yes yes touch events 1 finger

Slide 150

Slide 150

e-ink screens (slow, slower, slowest)

Slide 151

Slide 151

microscopic electrostatic charged balls

Slide 152

Slide 152

microscopic electrostatic charged balls + – – +

Slide 153

Slide 153

microscopic electrostatic charged balls + – – +

Slide 154

Slide 154

microscopic electrostatic charged balls

Slide 155

Slide 155

Slide 156

Slide 156

maybe css animations and transitions weren’t such a great idea after all

Slide 157

Slide 157

two completely different colors can look exactly the same in black and white

Slide 158

Slide 158

two completely different colors can look exactly the same in black and white

Slide 159

Slide 159

identifying e-readers (css for e-ink screens)

Slide 160

Slide 160

1 × css monochrome mediaquery @media (monochrome) { ... }

Slide 161

Slide 161

1 css monochrome mediaquery all tested e-readers act like they have a color screen

Slide 162

Slide 162

2 useragent sniffing there is no universal marker in the useragent string, but we can recognise individual manufacturers and models

Slide 163

Slide 163

Slide 164

Slide 164

portable consoles

Slide 165

Slide 165

66 Nintendo DSi 80 311 Nintendo 3DS New Nintendo 3DS 0 555 309 Sony PlayStation Vita portable console results html5test.com

Slide 166

Slide 166

Slide 167

Slide 167

two screens (surprisingly normal)

Slide 168

Slide 168

a dual visual viewport (the bottom one is the primary visual viewport) 3d screen, but only 2d is supported in the browser resistive touch screen

Slide 169

Slide 169

a dual visual viewport (the bottom one is the primary visual viewport) 3d screen, but only 2d is supported in the browser resistive touch screen

Slide 170

Slide 170

a dual visual viewport (the bottom one is the primary visual viewport) 3d screen, but only 2d is supported in the browser resistive touch screen

Slide 171

Slide 171

a dual visual viewport (the bottom one is the primary visual viewport) 3d screen, but only 2d is supported in the browser resistive touch screen

Slide 172

Slide 172

Slide 173

Slide 173

Slide 174

Slide 174

?weird browsers!

Slide 175

Slide 175

“We cannot predict future behavior from a current experience that sucks” – Jason Grigsby http://blog.cloudfour.com/on-the-device-context-continuum/

Slide 176

Slide 176

but wait…

Slide 177

Slide 177

weird browsers!

Slide 178

Slide 178

weird browsers!

Slide 179

Slide 179

rowsers browsers browsers browsers wsers! browsers! browsers! browsers browsers browser browsers browsers brows

Slide 180

Slide 180

one arm arm injury new parent situational permanent https://www.microsoft.com/en-us/design/practice

Slide 181

Slide 181

Slide 182

Slide 182

thank you niels leenheer @html5test