SlideShare uma empresa Scribd logo
1 de 71
Baixar para ler offline
Understanding Hardware
 Acceleration on Mobile
       Browsers

        Ariya Hidayat
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

Mais conteúdo relacionado

Mais procurados

Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Wakanda: NoSQL for Model-Driven Web applications - NoSQL matters 2012
Alexandre Morgaut
 

Mais procurados (10)

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

Destaque (11)

mobile hardware
mobile hardwaremobile hardware
mobile hardware
 
Smartphone Hardware Architecture
Smartphone Hardware ArchitectureSmartphone Hardware Architecture
Smartphone Hardware Architecture
 
Mobile Hardware
Mobile HardwareMobile Hardware
Mobile Hardware
 
Smartphone Component Trends and Outlook (Sept 2013)
Smartphone Component Trends and Outlook (Sept 2013)Smartphone Component Trends and Outlook (Sept 2013)
Smartphone Component Trends and Outlook (Sept 2013)
 
What is a smartphone-R1
What is a smartphone-R1What is a smartphone-R1
What is a smartphone-R1
 
Smartphone Hardware Architecture
Smartphone Hardware ArchitectureSmartphone Hardware Architecture
Smartphone Hardware Architecture
 
Smartphone HW Architecture
Smartphone HW ArchitectureSmartphone HW Architecture
Smartphone HW Architecture
 
Introduction to QtWebKit
Introduction to QtWebKitIntroduction to QtWebKit
Introduction to QtWebKit
 
Understanding Webkit Rendering
Understanding Webkit RenderingUnderstanding Webkit Rendering
Understanding Webkit Rendering
 
Mobile Application Architecture Strategy
Mobile Application Architecture StrategyMobile Application Architecture Strategy
Mobile Application Architecture Strategy
 
architecture of mobile software applications
architecture of mobile software applicationsarchitecture of mobile software applications
architecture of mobile software applications
 

Semelhante a Understanding Hardware Acceleration on Mobile Browsers

Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlight
rsnarayanan
 
Wp7 performance challenges
Wp7 performance challengesWp7 performance challenges
Wp7 performance challenges
Gergely Orosz
 
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Johan Andersson
 
D3 D10 Unleashed New Features And Effects
D3 D10 Unleashed   New Features And EffectsD3 D10 Unleashed   New Features And Effects
D3 D10 Unleashed New Features And Effects
Thomas Goddard
 
Adobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & TricksAdobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & Tricks
Mihai Corlan
 
阅读类Web应用前端技术探索
阅读类Web应用前端技术探索阅读类Web应用前端技术探索
阅读类Web应用前端技术探索
taobao.com
 

Semelhante a Understanding Hardware Acceleration on Mobile Browsers (20)

Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlight
 
GTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path RenderingGTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path Rendering
 
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
GDSC KIIT Huddle Session 4 - "Graphics Pipelining"
 
Wp7 performance challenges
Wp7 performance challengesWp7 performance challenges
Wp7 performance challenges
 
The Rendering Pipeline - Challenges & Next Steps
The Rendering Pipeline - Challenges & Next StepsThe Rendering Pipeline - Challenges & Next Steps
The Rendering Pipeline - Challenges & Next Steps
 
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006 Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
Actors, a Unifying Pattern for Scalable Concurrency | C4 2006
 
Hardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for AndroidHardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for Android
 
The Modern Web, Part 2: HTML5
The Modern Web, Part 2: HTML5The Modern Web, Part 2: HTML5
The Modern Web, Part 2: HTML5
 
FrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in Frostbite
 
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
 
D3 D10 Unleashed New Features And Effects
D3 D10 Unleashed   New Features And EffectsD3 D10 Unleashed   New Features And Effects
D3 D10 Unleashed New Features And Effects
 
Catan world and Churchill
Catan world and ChurchillCatan world and Churchill
Catan world and Churchill
 
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
 
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
SIGGRAPH Asia 2012: GPU-accelerated Path RenderingSIGGRAPH Asia 2012: GPU-accelerated Path Rendering
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
 
FGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie TycoonFGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie Tycoon
 
Adobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & TricksAdobe AIR - Mobile Performance – Tips & Tricks
Adobe AIR - Mobile Performance – Tips & Tricks
 
Svcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobileSvcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobile
 
Advanced Web Graphics with Canvas
Advanced Web Graphics with CanvasAdvanced Web Graphics with Canvas
Advanced Web Graphics with Canvas
 
阅读类Web应用前端技术探索
阅读类Web应用前端技术探索阅读类Web应用前端技术探索
阅读类Web应用前端技术探索
 
阅读类 Web 应用前端技术探索
阅读类 Web 应用前端技术探索阅读类 Web 应用前端技术探索
阅读类 Web 应用前端技术探索
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Understanding Hardware Acceleration on Mobile Browsers