SlideShare a Scribd company logo
Understanding Hardware
 Acceleration on Mobile
       Browsers

        Ariya Hidayat
Understanding Hardware Acceleration on Mobile Browsers
Magical Advice
                 Use translate3d for hardware
                         acceleration
Challenges
Game vs Web
Game

                                    Text




                                           Textured objects
       Animation



              Transformation   Physics
Large but Still Bounded
Web Page



                  Images

           Text
Challenges




    Predictable contents (assets)   ✔
    Mostly text                           ✔
    Mostly images                   ✔
    Initial response                    immediate
Browser Rendering
From Wave to Pixels


                       Network stack



                                  Layout engine



                      JavaScript engine           Graphics




                                          User interface
WebKit Components
                                   Render Engine

                                       CSS
                     DOM                                 SVG



         HTML                                                        Canvas

                                     WebCore




                Client Interface               JavaScript Engine (JSC/V8)
Platform Abstraction


           Network      Unicode      Clipboard


          Graphics       Theme        Events


           Thread      Geolocation    Timer
Graphics Abstraction


  GraphicsContext       iOS        Android




                                    Skia
                    CoreGraphics

                                             Graphics stack
SoC = System-on-a-Chip




                         CPU   GPU
GPU Workflow




               Matrix




  Vertices              Rendered   Textured
Optimized for Games


                      “Fixed” geometry

                      Transformation

                      Textured triangles



                                 Parallelism
Powerful Capabilities




 http://epicgames.com/technology/epic-citadel   http://www.rage.com/
http://www.trollquotes.org/619-super-spider-bat-troll-quote/
Fundamental Physical Limitations


    Memory
     - Can’t store too much stuff
    Speed
     - Quad-core CPU can do certain operations better
    Bandwidth
     - Bottleneck can be in the data transfer
Traffic Congestion
Primitive Drawing
Path is Everything




                     Triangle   Rectangle




             Path
                     Ellipse         Polygon
Stroke = Outline




            Solid   Dashed   Dotted   Textured
Brush = Fill




   None        Solid   Gradient   Textured
Gradient = Non-uniform Pixel Values
Drawing Time: Solid vs Gradient


       Only border

      Solid color fill
                                           14x slower
                                  (depending on the dimension)
 Linear gradient fill

 Radial gradient fill
Path Approximation

          Curves




                     Polygon
Smooth via Antialiasing

                          Multiple levels of transparency




                                        Perfect for parallelism
Shadow

  Involved pixel “blending”   Often obstructed
Drawing Time: Solid vs Blur Shadow



                                              20x slower
  Solid shadow                       (depending on the blur radius)


  Blur shadow
CSS = Box Model




http://www.w3.org/TR/CSS2/zindex.html   Appendix E. Elaborate description of Stacking Contexts
Shadow Abuse




     12,000 pixels




                     Blur shadow
Transformation




     Scaling
                            Perspective
                 Rotation
Text Rasterization
Font Atlas

             Buffer




                      Bye
From Simple to Complex

                                                  ello!
                                                H



                                                   Curves
         Simple shape                          Gradient brush
          Solid color                          Textured stroke
                                                Blur shadow
                                                  Serif text
                                                  Rotated

                         Make it as an image
Library Instrumentation
                     platformInit
                     savePlatformState
                     translate 0,0
                     translate 0,0
                     clip 1,0 0x6.95322e-310
                     fillRect 0,0 800x556 color   ff ff ff ff
                     restorePlatformState
                     platformDestroy
                     platformInit
                     savePlatformState
                     translate 0,0
                     translate 0,0
                     clip 1,0 0x6.95322e-310
                     fillRect 0,0 800x556 color   ff ff ff ff
                     restorePlatformState
                     platformDestroy
                     platformInit
                     savePlatformState
                     translate 0,0
                     translate 0,0
                     clip 1,0 0x6.95322e-310
                     fillRect 0,0 800x556 color   ff ff ff ff
                     fillRect 0,0 800x556 color   ff ff ff ff
Painting Performance


                       16:24:04.070   D/webcoreglue(    273):   drawContent   11   ms
                       16:24:04.110   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:04.150   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:04.190   D/webcoreglue(    273):   drawContent   10   ms
                       16:24:04.240   D/webcoreglue(    273):   drawContent   10   ms
                       16:24:04.280   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:04.320   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:04.360   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:06.080   D/webcoreglue(    273):   drawContent   12   ms
                       16:24:06.140   D/webcoreglue(    273):   drawContent   10   ms
                       16:24:06.180   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:06.230   D/webcoreglue(    273):   drawContent   14   ms
                       16:24:06.600   D/webcoreglue(    273):   drawContent   26   ms
                       16:24:06.640   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:06.860   D/webcoreglue(    273):   drawContent   33   ms
                       16:24:06.890   D/webcoreglue(    273):   drawContent   12   ms
                       16:24:06.930   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:06.960   D/webcoreglue(    273):   drawContent   13   ms
                       16:24:07.000   D/webcoreglue(    273):   drawContent   13   ms
Backing Store
Maps

       Tiles
Responsive Interface



             Rendering




                         Processor
                                     User interaction
Pinch to Zoom




  when you pinch...
Rendering vs Interaction

          Rendering




   Web Page                User interaction
Checkerboard Pattern




                       Poor man’s indicator
                         of performance
Progressive Rendering
       Fast but blurry




                         Crisp but slow
Perceived Responsiveness

        User pinches




                                            Smooth scaled


                       Blocky (but fast!)
Tiling System




                               ....                ....


                      CPU                                 GPU
                                        Streamed




                 What happens if the page
                background changes color?
Tile Transformation




        Panning = Translation   Zooming = Scaling
Y U NO
position:fixed
Layer & Compositing
Typical Animation




              opacity, movement, scaling, rotation, ...
Principles of Fluid Animation




               At the beginning, push as many resources
         1               as possible to the GPU


                 During the animation, minimize
         2            CPU-GPU interaction
Immediate vs Retained

                               At the beginning...


                                                     draw the shape onto a buffer



                         For every animation tick...


    draw the shape at (x, y)                         blit the buffer at (x, y)
    x = x + 10                                       x = x + 10


                                                                 Off main thread
Mechanics of Animation
                       “Hey, this is good stuff. Cache it as texture #42.”




      Initialization




                             “Apply [operation] to texture #42.”


     Animation step
Elements = Layer
Logical 3-D
Compositing By Force

                    -webkit-transform: translateZ(0)




                    Not needed for CSS animation!

         .someid {
             -webkit-animation-name: somekeyframeanimation;
             -webkit-animation-duration: 7s;
             -webkit-transform: translateZ(0);
         }
                                   Don’t do that
Debugging in Safari

        defaults write com.apple.Safari IncludeInternalDebugMenu 1
Compositing Indicators


                         Texture (number = upload)

                                Composited layer



                         No associated texture

                                 Container layer

                                    Overflow
Avoid Texture Reupload


            No reupload                            Upload




             Opacity
             Position                         Everything else!
              Size
            Animation



                     “Hardware accelerated CSS”
Examples
Color Transition
        @-webkit-keyframes box {
            0% { -webkit-transform: background-color: blue; }
          100% { -webkit-transform: background-color: green; }
        }




                        Need a new texture uploaded to the
                          GPU for every in-between color
Color Transition: The Trick




                          Blended with
Prepare and Reuse




                          Hide the layer offscreen




               Viewport
Timer Latency


                                                        Depending on
                                                        user reaction




           •Animation end triggers the JavaScript callback
           •JavaScript code kicks the next animation

                           Prepare both animation and
                              hide the “wrong” one
Avoid Overcapacity

                              Texture upload




                       ....               ....




              Think of the GPU memory like a cache.
Wrap-up
Hardware Acceleration




       Drawing primitives   Backing stores   Layer & compositing
There is no such



  Traditional graphics
programming has been
  always full of tricks.

  It will always be.
Thank You


       ariya.hidayat@gmail.com    Office Hour

                                 Wed 1:45 PM
        ariya.ofilabs.com



        @AriyaHidayat

More Related Content

PDF
Understanding Hardware Acceleration on Mobile Browsers
PDF
Writing Tools using WebKit
PDF
Analyzing the Performance of Mobile Web
PDF
Build HTML5 App (Intel Elements 2011)
PPTX
Siggraph 2016 - Vulkan and nvidia : the essentials
PDF
Going to Mars with Groovy Domain-Specific Languages
PPTX
HTML5 - A Whirlwind tour
PDF
Introduction to WebGL and WebVR
Understanding Hardware Acceleration on Mobile Browsers
Writing Tools using WebKit
Analyzing the Performance of Mobile Web
Build HTML5 App (Intel Elements 2011)
Siggraph 2016 - Vulkan and nvidia : the essentials
Going to Mars with Groovy Domain-Specific Languages
HTML5 - A Whirlwind tour
Introduction to WebGL and WebVR

What's hot (10)

PPTX
NvFX GTC 2013
PDF
Minimalism in Web Development
PDF
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
PPT
GWT Extreme!
PDF
Groovy & Grails for Spring/Java developers
PDF
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
PPTX
iOSDC 2018 動画をなめらかに動かす技術
PDF
Asynchronous Module Definition (AMD)
PDF
Intro to HTML5
PDF
Performance Improvements in Browsers
NvFX GTC 2013
Minimalism in Web Development
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
GWT Extreme!
Groovy & Grails for Spring/Java developers
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
iOSDC 2018 動画をなめらかに動かす技術
Asynchronous Module Definition (AMD)
Intro to HTML5
Performance Improvements in Browsers
Ad

Viewers also liked (11)

PPTX
mobile hardware
PPTX
Smartphone Hardware Architecture
PPTX
Mobile Hardware
PPTX
Smartphone Component Trends and Outlook (Sept 2013)
PPTX
What is a smartphone-R1
PPTX
Smartphone Hardware Architecture
PPTX
Smartphone HW Architecture
PDF
Introduction to QtWebKit
PDF
Understanding Webkit Rendering
PDF
Mobile Application Architecture Strategy
PPTX
architecture of mobile software applications
mobile hardware
Smartphone Hardware Architecture
Mobile Hardware
Smartphone Component Trends and Outlook (Sept 2013)
What is a smartphone-R1
Smartphone Hardware Architecture
Smartphone HW Architecture
Introduction to QtWebKit
Understanding Webkit Rendering
Mobile Application Architecture Strategy
architecture of mobile software applications
Ad

Similar to Understanding Hardware Acceleration on Mobile Browsers (20)

PDF
Korea linuxforum2014 html5game-sangseoklim
PPT
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
PPT
GTC 2012: GPU-Accelerated Path Rendering
PDF
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
PDF
Redefining Mobile Graphics Stack
PDF
Hardware Accelerated 2D Rendering for Android
PPT
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
PPTX
Deep Dive into Microsoft Silverlight Graphics
PDF
[SSS 2nd] 빅포게임즈 HTML 유무선연동
PDF
Going Mobile - A Pragmatic Look At Mobile Design
PDF
MS TechDays 2011 - HTML 5 All the Awesome Bits
PPTX
HTML5, Silverlight & Kinect
PPTX
Flash Gamm 2011,"Stage3D survival guide"
PDF
I Can't Believe It's Not Flash
PDF
3 d to _hpc
PDF
Neurotech Solutions Ltd: Рекомендации по Stage3D: выбор наиболее подходящего ...
PPTX
Penn graphics
PPTX
CanvasGL, a GPU-accelerated WebKit
PPTX
Introducing canvas gl (company100)
PDF
2D Games to HPC
Korea linuxforum2014 html5game-sangseoklim
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
GTC 2012: GPU-Accelerated Path Rendering
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
Redefining Mobile Graphics Stack
Hardware Accelerated 2D Rendering for Android
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
Deep Dive into Microsoft Silverlight Graphics
[SSS 2nd] 빅포게임즈 HTML 유무선연동
Going Mobile - A Pragmatic Look At Mobile Design
MS TechDays 2011 - HTML 5 All the Awesome Bits
HTML5, Silverlight & Kinect
Flash Gamm 2011,"Stage3D survival guide"
I Can't Believe It's Not Flash
3 d to _hpc
Neurotech Solutions Ltd: Рекомендации по Stage3D: выбор наиболее подходящего ...
Penn graphics
CanvasGL, a GPU-accelerated WebKit
Introducing canvas gl (company100)
2D Games to HPC

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Encapsulation theory and applications.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Machine learning based COVID-19 study performance prediction
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Understanding_Digital_Forensics_Presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation_ Review paper, used for researhc scholars
Encapsulation theory and applications.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Advanced methodologies resolving dimensionality complications for autism neur...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Machine learning based COVID-19 study performance prediction
Reach Out and Touch Someone: Haptics and Empathic Computing

Understanding Hardware Acceleration on Mobile Browsers