The intersection of performance and accessibility

A presentation at #PerfMatters in April 2019 in Redwood City, CA, USA by Eric Bailey

Slide 1

Slide 1

  • The intersection of Performance & Accessibility, #PerfMatters 2019

Slide 2

Slide 2

  • So, let’s set the stage

Slide 3

Slide 3

  • We’re at a conference about performance,
  • With performance being the manner in which a mechanism behaves

Slide 4

Slide 4

  • I was conducting some accessibility auditing last year
  • Which is the process of performing manual and automated checks to see if a website can work with assistive technology
  • The client was a medical education app used to train caregivers

Slide 5

Slide 5

  • It was built using a single page application framework, using Google’s Material Design library to build the user interface

Slide 6

Slide 6

  • When I learned that, I thought:
  • Google made it? Oh sweet. I don’t have to worry as much.
  • So I fire up VoiceOver, macOS’s screen reader and start testing.
  • Things are going pretty well and then

Slide 7

Slide 7

  • VoiceOver crashes!
  • I try restarting Safari, I try clearing the cache, I try closing other tabs. Heck, I even try rebooting
  • Same result every time
  • So, I ask my boss what’s going on, and he says, “Oh, it’s probably problems with the Accessibility Tree.”

Slide 8

Slide 8

  • The what now?
  • Before I get more into this, here’s a question for you:
  • How do you describe an interface?
  • I’m not saying, “tell me what you see or hear after you turn the computer on.”
  • I’m saying how do you speak computer to a computer

Slide 9

Slide 9

  • The way we do that is with the Accessibility Tree
  • Fundamentally, it is is a collection of objects, all the atomic bits that make up a user interface
  • People who rely on assistive technology use the Accessibility Tree to navigate and take action on user interfaces
  • Without a functioning Accessibility Tree there is no way to describe the current state of what an interface is
  • And consequently no way for some people to be able to use a computer or smartphone
  • So suffice to say it’s a really important piece of technology!
  • So, how do you build an Accessibility Tree?

Slide 10

Slide 10

  • First, you have to give each individual object in an interface a Name
  • Names are a short identifiers used to describe purpose.

Slide 11

Slide 11

  • Then you give it a Role
  • Roles are predefined values that tell someone what they can do to the interface object
  • For example, a role of button means that someone can press it to activate some predefined action

Slide 12

Slide 12

  • Then we have Properties, which are the attributes of the object
  • Examples of this are its position in an interface, it’s state, or interactions that are allowed
  • For a button, that could mean a disabled state to prevent it from being clicked on

Slide 13

Slide 13

  • Finally, we have a Description which can provide further information about the object, if needed
  • These accessible objects are then programmatically grouped together to form more complicated interface components
  • So, how do you build these interface components?

Slide 14

Slide 14

  • Let’s say an operating system alert dialog, that’s a pretty commonplace thing for UI

Slide 15

Slide 15

  • Starting from the top down, we have a menubar
  • That’s the anchor that we’re going to attach everything to

Slide 16

Slide 16

  • And then we add a title for the menubar, so we know what it’s all about, and what contents we can expect to find
  • If you’re using a screen reader, titles are really helpful, as it saves you from having to dig around inside the component to figure out what it’s for

Slide 17

Slide 17

  • We might also need to close this dialog window once we learn what it’s for, so we include a close button in the menubar

Slide 18

Slide 18

  • Then we add the body of the dialog, the place where we can place the bulk of the dialog content

Slide 19

Slide 19

  • In the dialog’s body there’s another title, which asks us if we want to save the changes we made to the thing we were working on

Slide 20

Slide 20

  • We then add text to the body, which will provide more information about what happens if you choose not to save

Slide 21

Slide 21

  • Then we add a save button, to allow us to commit to saving the changes we made

Slide 22

Slide 22

  • And an accompanying cancel button, in case we don’t
  • And presto! We have a dialog component!

Slide 23

Slide 23

  • Because these collected objects have accessible names and are therefore present in the Accessibility Tree, we can speak computer to computer to get what we want

Slide 24

Slide 24

  • I can programatically say “go to the dialog

Slide 25

Slide 25

  • Then it’s body

Slide 26

Slide 26

  • and activate the save button
  • and it works!

Slide 27

Slide 27

-So, this might seem a little pedantic, but please bear with me for a bit

Slide 28

Slide 28

  • We do have this dialog component, but there’s more to it than just that

Slide 29

Slide 29

  • Interface components have to have a place to live, and that place is an operating system

Slide 30

Slide 30

  • Operating systems also include components that allow us to navigate to, and access the stuff you store on them

Slide 31

Slide 31

  • It’s also the place we install and run programs

Slide 32

Slide 32

  • And all the little doodads and widgets we can’t live without

Slide 33

Slide 33

  • And the browser, which is rapidly becoming an operating system in it’s own right

Slide 34

Slide 34

  • The browser contains the mechanisms we use to access the web
  • And the web is sort of the Wild West in that you can write more or less whatever you want and it’ll usually work, which is both a blessing and a curse

Slide 35

Slide 35

  • But regardless of how you write what you write, you can’t escape the fact that you have to ultimately create HTML

Slide 36

Slide 36

  • That HTML then has its appearance and behavior augmented by both JavaScript and CSS
  • Again, there’s many ways to go about doing this, but they are the other two requisite parts that make up the whole that is a website or web app

Slide 37

Slide 37

  • The HTML markup, augmented by both JavaScript and CSS creates the Document Object Model, or DOM tree, which is a programming interface for websites

Slide 38

Slide 38

  • Browsers then read the DOM, and all the information contained within it to draw an interface

Slide 39

Slide 39

  • Which is then shown to a user

Slide 40

Slide 40

  • The user can then take actions, which updates the DOM, which in turn updates what is visually rendered, allowing us to make our websites dynamic

Slide 41

Slide 41

  • Running in parallel is the Accessibility Tree, which is sampled from the generated DOM
  • I say sampled because the Accessibility Tree will use specialized heuristics to only surface things it deems necessary
  • Modern versions of the Accessibility Tree are generated after styles are computed, as certain CSS properties such as display and pseudo element content will affect it

Slide 42

Slide 42

  • This sampled version of the DOM is then read by various kinds of assistive technology, including, but not limited to screen readers
  • There’s two things I’d like to point out here:

Slide 43

Slide 43

  • First, using a visually rendered interface and assistive technology aren’t mutually exclusive
  • Not all screen reader users are blind
  • Many people choose to augment their visual browsing with devices that rely on the Accessibility Tree

Slide 44

Slide 44

  • Secondly, the Accessibility Tree relies on the user interacting with the DOM to update
  • It’s effectively a “read only” technology, in that we can’t directly work with it

Slide 45

Slide 45

  • Another thing you should be aware of is that it’s more an accessibility forest than an Accessibility Tree
  • There are different implementations of the Accessibility Tree, each depends on what operating system you’re using, and what version of said operating system is running
  • This is due to the different ways companies have built and updated their operating system’s underlying code

Slide 46

Slide 46

  • Just so we’re clear:

Slide 47

Slide 47

  • The DOM can be a part of the Accessibility Tree, but the Accessibility Tree is larger, and not limited to just the contents of your browser

Slide 48

Slide 48

  • Because of this, the accessibility tree is more brittle
  • It has more to pay attention to, and it’s technical architecture was developed before this whole internet thing really took off
  • Meaning it didn’t anticipate the sheer amount of information we’d be throwing at it.

Slide 49

Slide 49

  • Crashing the Accessibility Tree, and therefore breaking assistive tech support is bad, yes
  • But a large amount of information present in the DOM means that there’s an accompanying large amount of work the Accessibility Tree needs to do to figure out what’s what and report on it
  • Which slows. it. down.

Slide 50

Slide 50

  • This can create a lack of synchronization between the current state of the page and what is being reported by assistive tech
  • Meaning that a user may not be working with an accurate model of current screen, and be taking action on interactive components that are no longer present
  • This can create the confusing experience of activating wrong control or navigating to a place they didn’t intend to
  • So, how do we help prevent this?

Slide 51

Slide 51

  • Start with writing semantic HTML
  • Using things like the button element for buttons instead of ARIA slapped on a div helps lessen the amount of guesswork the Accessibility Tree has to do when it runs its heuristics to slot meaningful content into its description of the current state of things.
  • This serves to both speeds up its calculation and makes what it reports more reliable

Slide 52

Slide 52

  • And speaking of semantic HTML
  • Here’s the raw, living DOM tree of an actual website
  • In fact, it’s the website for this conference! Estelle, sorry not sorry

Slide 53

Slide 53

  • Even a static, performant website contains a lot of information a computer has to chew through

Slide 54

Slide 54

  • Again, utilizing semantic HTML, like the markup present here, helps reduce the effort it takes to generate the Accessibility Tree

Slide 55

Slide 55

  • And unfortunately, using semantic HTML is kind of a rare thing these days, which is partly why I’m here giving this talk

Slide 56

Slide 56

  • Okay, I think you get the gist of it

Slide 57

Slide 57

  • Of the code I just showed you, five slide’s worth,

Slide 58

Slide 58

  • We’ve only covered the top quarter of just the homepage
  • Again, it’s a lot of stuff to process

Slide 59

Slide 59

  • Keeping that DOM tree example in mind, we now have a simple form
  • It’s a pair of unstyled radio buttons asking you if you want the chicken or the fish as your meal preference

Slide 60

Slide 60

  • Here’s how that form might be translated into the Accessibility Tree
  • If we use semantic HTML, the names, roles, and properties are automatically filled in for us without any additional effort
  • When I was speaking about how semantic HTML slots in, this is a more granular example of what I’m getting at

Slide 61

Slide 61

  • Here’s a more high fidelity example, sampled again from the PerfMatters homepage
  • I’m using Firefox’s Accessibility Inspector to dig into a link
  • There’s a ton more information exposed, including attributes, states, actions, a child element count, relations, and available actions
  • All of this data is used by the Accessibility Tree to help it describe the shape of things

Slide 62

Slide 62

  • And here’s an even more high fidelity example, a raw text dump of the Accessibility Tree for this same page
  • This is an example of what the language might look like when we’re speaking machine directly to machine.

Slide 63

Slide 63

  • We don’t speak machine directly, though
  • Before we had Firefox’s Accessibility Inspector, we had to rely on more specialized tools to be the translators
  • The Paciello Group’s aViewer and Apple’s Accessibility Inspector are the two go-to resources
  • And you’ll still need them if you want to inspect anything other than websites, or do some really serious digging

Slide 64

Slide 64

  • So, let’s make the abstract immediate
  • What going on here, and why should you care?

Slide 65

Slide 65

  • With my auditing project, I narrowed the problem down to issues with Material Design’s radio inputs
  • Here’s how they appear visually

Slide 66

Slide 66

  • And here’s how they appear in code

Slide 67

Slide 67

  • To make a Material Design radio input, you need
  • Six HTML elements containing nine attributes, with a DOM depth of 3

Slide 68

Slide 68

  • You also need 66 CSS selectors containing 141 properties, which weighs in at 10k when minified

Slide 69

Slide 69

  • You will also need 2,374 lines of JavaScript, which weighs in at 30k minified

Slide 70

Slide 70

  • All that will get us a radio input

Slide 71

Slide 71

  • But you need more than one radio input to be able to use it properly

Slide 72

Slide 72

  • And oftentimes there’s a few options to select from

Slide 73

Slide 73

  • Sometimes there’s more than just a few options

Slide 74

Slide 74

  • And sometimes there’s even more than that

Slide 75

Slide 75

  • In the case of my audit, we had a ton of radio inputs conditionally being injected into the page

Slide 76

Slide 76

  • This all adds up

Slide 77

Slide 77

  • Google’s Lighthouse project, an open source tool that analyzes your website for performance problems, recommends an optimal website DOM tree has the following:
  • Less than 1,500 nodes
  • Max depth of 32 nodes
  • No parent node with more than 60 child nodes

Slide 78

Slide 78

  • What I’d like to call attention to is the max depth of 32 nodes bit
  • That might seem like a lot of wiggle room at first, but take a moment and think about the templates of the sites you’ve worked on.
  • There’s the frameset, wrapper divs, landmarks, components wrappers and if you’re doing it right, fieldsets on your forms
  • Each digging a little bit more inward

Slide 79

Slide 79

  • Another part of accessibility auditing is providing a fix to the problems you uncover
  • It’s tough work, but nobody likes to pay people money to tell them all the things that are wrong, but offer no solutions
  • We wound up recommending a radio input pattern that utilized three HTML elements

Slide 80

Slide 80

  • It’s a pattern developed by my friend Scott, taken from his excellent a11y_styled_form_controls project
  • It’s worth saying that Scott puts these patterns through their paces, and tests them with an incredibly robust set of assistive technologies
  • So a nice side benefit is knowing I can recommend them with confidence

Slide 81

Slide 81

  • Visually, it was completely indistinguishable from the original version

Slide 82

Slide 82

  • To compare the two solutions

Slide 83

Slide 83

  • We have a 50% reduction in HTML elements, and we cut the DOM depth down by a third

Slide 84

Slide 84

  • There’s also a 30% reduction in CSS selectors and properties, resulting in the CSS payload for this pattern being reduced by 90%

Slide 85

Slide 85

  • We’ve also completely removed 30k of JavasScript, which is 30k less blocking resource being served

Slide 86

Slide 86

  • Cobbling up a rough prototype, we were able to create an environment that mimicked the conditions of the site we were auditing, only using the new radio input code and guess what?

Slide 87

Slide 87

  • It worked! VoiceOver didn’t crash!

Slide 88

Slide 88

  • So why is this our problem?
  • Why should we care about the fragility of other people’s software?

Slide 89

Slide 89

  • Well, prioritizing developer ergonomics without considering the generated HTML can lead to bad things happening

Slide 90

Slide 90

  • And regardless of our setup, we tend to pile even more things on to our base experience

Slide 91

Slide 91

  • Things like ads

Slide 92

Slide 92

  • Analytics

Slide 93

Slide 93

  • Social marketing engagement tools

Slide 94

Slide 94

  • And development integration utilities

Slide 95

Slide 95

  • And then there’s the also cold war raging between websites and their users
  • Here is Facebook splitting a single word into 11 DOM elements to avoid ad blockers

Slide 96

Slide 96

  • This graph is generated from median values of how 1.3 million websites are generated, with JavaScript claiming the majority of the share.
  • This JavaScript majority means it’s that much more time spent blocking the browser from performing other other actions, including things like interfacing with assistive technology

Slide 97

Slide 97

  • When we throw out what the browser gives us for free, we oftentimes don’t realize there are very real, very important things we sacrifice in doing so

Slide 98

Slide 98

  • Here’s what Marco Zehe, Mozilla’s senior Accessibility QA Engineer has to say about all this:
  • Nibbling away at those milliseconds it takes for information to reach assistive technologies when requested. My current task is to reduce the number of accessible objects we create for html:div elements. This is to reduce the size of the accessibility tree.

Slide 99

Slide 99

  • This reduces the amount of data being transferred across process boundaries. Part of what makes Firefox accessibility slower on Windows since Firefox Quantum is the fact that assistive technologies now no longer have direct access to the original accessible tree of the document.

Slide 100

Slide 100

  • A lot of it needs to be fetched across a process boundary. So the amount of data that needs to be fetched actually matters a lot now. Reducing that by filtering out objects we don’t need is a good way to reduce the time it takes for information to reach assistive technologies.

Slide 101

Slide 101

  • This is particularly true in dynamically updating environments like Gmail, Twitter, or Mastodon. My current patch, slatted to land early in the Firefox 67 cycle, shaves off about 10 to 20% of the time it takes for certain calls to return.

Slide 102

Slide 102

  • Note that all this optimization is only for one browser, Firefox

Slide 103

Slide 103

  • And that there are a lot of browsers out there

Slide 104

Slide 104

  • It’s also not all about browsers, either
  • Here’s a refreshable braille display, one of many other kinds of assistive technology that interfaces with the accessibility tree

Slide 105

Slide 105

  • “Someone should do something!” The battle cry of bystanders everywhere
  • Let’s unpack this some, and figure out our available options

Slide 106

Slide 106

  • For screenreaders, the main ones are JAWS

Slide 107

Slide 107

  • And NVDA
  • Both are Windows screen readers

Slide 108

Slide 108

  • VoiceOver for macOS and iOS

Slide 109

Slide 109

  • And Talkback for Android
  • These are the big four screen readers you’re going to hear about
  • It’s sort of analogous to Chrome, Safari, Firefox, and IE, in that there’s more screen readers out there, but these cover the main use cases you’re most likely to deal with
  • While not all assistive technology are screen readers, if your site works well for them, chances are good it’ll work well for other assistive tech

Slide 110

Slide 110

  • Of them, all but one have an open issue tracker

Slide 111

Slide 111

  • But half have closed source code
  • This means that while we can file issues, we aren’t really empowered to do much more about it on the assistive technology layer
  • It’s also completely unrealistic to expect people to submit and follow issues or code pull requests across all trackers in addition to working a full-time job

Slide 112

Slide 112

  • Our only other realistic option is to keep the DOM trees on our sites nice and shallow
  • There are actual, tangible benefits to doing this

Slide 113

Slide 113

  • Here’s Marco again weighing in again on his optimization efforts:
  • Reducing the number of milliseconds it takes for a screen reader to start speaking after a key press from about 140 to 100 here, or from 120 to 100 there, doesn’t matter much on a fast machine. On a slow machine, that reduction is from about 230 to 250 down to 200 or 190.

Slide 114

Slide 114

  • Let’s talk about what slow machines means
  • If you are disabled and/or underserved, you face significant barriers to entering and staying in the workforce
  • This means you may have less access to current technology, especially the more expensive, higher quality versions of it
  • Another factor is some people who rely on assistive technology are reluctant to upgrade it, for a very justified fear of breaking the way they use to interact with the world

Slide 115

Slide 115

  • Slow machines may also not mean an ancient computer
  • Inexpensive Android smartphones are a common entry point for emerging markets, and with Android comes Talkback

Slide 116

Slide 116

  • A slow machine might also come from a place you may not be expecting
  • By which I mean you might have a state-of-the-art computer and are doing state-of-the-art things on it
  • This requires a ton of computational resources, which makes fast things slow
  • With less computational resources to go around, we may have unintended consequences, possibly re-creating a situation similar to our too many radio inputs problem

Slide 117

Slide 117

  • Think Electron apps, desktop programs that are built with web technologies

Slide 118

Slide 118

  • Accessibility auditing isn’t something people normally do out of the goodness of their own heart
  • It’s typically performed after a lawsuit has been levied against an organization
  • Let me be clear: when you create inaccessible experiences, you are denying people their civil rights
  • The Americans With Disabilities Act guarantees that people cannot be discriminated against based on their disability conditions, and this extends to both private organizations and the digital space
  • This is a good thing, as it guarantees protections as more and more of the services necessary to living life go online

Slide 119

Slide 119

  • You need to work with what you have, not what you hope will be
  • Part of this means understanding that when we want things to be better, we need to understand that these kinds of changes are really technically complicated under the hood and spread across multiple concerns
  • On top of that, accessibility fixes are often viewed as unglamorous and deprioritized compared to other features
  • Don’t believe me?

Slide 120

Slide 120

  • Here’s the support matrix for the title attribute, incorporated into the W3C’s HTML spec in 1993.
  • It’s 26 years later and we still have a ton of interoperability problems.

Slide 121

Slide 121

  • I don’t mean to bum you out, and I don’t expect you to become accessibility experts
  • However, as people who are interested in more than just the surface level of things, you are uniquely empowered to affect positive change
  • What I ask of you is to at least incorporate basic accessibility testing into your workflow
  • If anything, just check to see if a screen reader crashes:
  • A bad assistive technology experience is better than none at all

Slide 122

Slide 122

  • Whoa!
  • The slide background is yellow now!

Slide 123

Slide 123

  • This is what we call a great segue

Slide 124

Slide 124

  • I’m a designer by trade,
  • Part of that job means coming up with alternate strategies for allowing people to accomplish their goals
  • because sometimes the most effective solution isn’t necessarily the most obvious one

Slide 125

Slide 125

  • With that in mind, we’re going to talk about another definition of performance, which is the ability to actually accomplish something
  • All of these little surgical tweaks and optimizations don’t mean squat if people don’t understand how to operate the really fast thing you give them

Slide 126

Slide 126

  • Another aspect of dynamically injecting a ton of radio inputs into a page is that it adds more things for a person to think about
  • This is called cognitive load, and it’s a huge problem
  • It affects our ability to accomplish tasks, and accomplish tasks accurately

Slide 127

Slide 127

  • Namely it inhibits our memory

Slide 128

Slide 128

  • Problem-solving skills

Slide 129

Slide 129

  • Attention

Slide 130

Slide 130

  • Reading comprehension level

Slide 131

Slide 131

  • Math comprehension level

Slide 132

Slide 132

  • And shockingly, our ability to actually understand what we see

Slide 133

Slide 133

  • It’s such an important problem that NASA developed the Task Load Index, an assessment tool to help quantify it
  • This isn’t warm fuzzy feelings about empathy, this is a serious attempt by a government agency to refine efficiencies and prevent errors
  • One of the most interesting things about the existence of the Index is that it’s an admission that disability conditions can be conditional
  • Think about it: when’s the last time you were tired, distracted, sick, or learning a new skill?
  • Heck, when’s the last time you were drunk?
  • Cognitive load an important thing to track for building rockets, sure
  • But it also translates to other complicated things like making and using software

Slide 134

Slide 134

  • One of the things we can do to lessen cognitive load is to lessen the amount of information someone has to parse at any given moment

Slide 135

Slide 135

  • For the medical education app, we could have added an additional step into the user flow that asks a high level segmenting question
  • It’s a little more friction, sure
  • but it’s being used strategically as a focused choice, to keep the cognitive load lower

Slide 136

Slide 136

  • This would help filter down the results you get
  • Which makes it both easier for the person and the browser to parse

Slide 137

Slide 137

  • The other big-picture question we need to ask is if all this work is even necessary?
  • The most performant page is the one you never have to use, by which I mean how often can we side-step these issues by using other resources and information made available to us?

Slide 138

Slide 138

  • If you’re interested in this sort of thing, the 2018 Design in Tech report is a must-read piece
  • One of the things it was revealed is that surprisingly very few companies conduct qualitative user research
  • Which is the practice of asking people how they’d use a feature, and how they feel while they do it

Slide 139

Slide 139

  • I’m not a numbers person, but there does seem to be a trend going on here
  • Another interesting thing is barely any companies conduct qualitative testing for features after launching them
  • So we’re all just throwing features into the larger, ever-evolving ecosystem that is your product and not checking to see how it’ll affect things

Slide 140

Slide 140

  • We also need to remember that we’re only seeing those companies that beat the odds
  • The market is built on top of the corpses of failed businesses who poured all their cash and resources into the wrong features

Slide 141

Slide 141

  • The second big ask from this talk is really just repeating the first one
  • It’s one thing to read about something and believe it to be true, but it’s another thing entirely to put it out into the world without verifying it works

Slide 142

Slide 142

  • The web, and more importantly, the people who use it, are too important not to

Slide 143

Slide 143

  • Thank you to our captioner,
  • Michelle and the other staff
  • Mina for being a great emcee
  • Estelle for organizing such a wonderful conference
  • And most importantly, you, our audience
  • The slides for this talk are available online on Notist
  • And I’ll be both tweeting out a link to it and linking to it on my personal website

Slide 144

Slide 145

Slide 146

Slide 147

Slide 148