SlideShare a Scribd company logo
Why you should
use React Canvas
Arwa Lokhandwala
Senior Full Stack Developer
@BookMyShow
@arwa1893
Agenda
● The Jank problem
● Why the Jank happens
● Understanding the Rendering process
● How to optimize scrolling performance
● Knowing the React-canvas
● How react canvas actually works
● Limitations of React-canvas
● Alternative libraries
● Demo
The Jank problem
“Jank” is any stuttering or choppiness that a
user experiences when there is motion on
the screen—like during scrolling, transitions,
or animations.
Why the Jank happens ???
● Most of the devices refresh their screens 60 times a
second
● The browser needs to match the device’s refresh
rate and put up 1 new picture, or frame, for each of
those screen refreshes.
● Each frame has a budget of 1000/60 = 16.66 ms
Understanding the Rendering Process
1. Calculate
2. Layout
3. Paint
4. Composite
Optimizing scrolling performance
● Avoid Expensive Styles
● Keep Reflows and Repaints to minimum ( Ex : offsetTop
property)
● Debounce your scroll events
React Canvas
Adds the ability to react components to render to canvas
rather than the DOM
Bridge or Surface Component
Group Component
Primitive
Component
Primitive
Component
How react canvas actually works
Primitive Component & Layer component
● Basic building blocks of your custom renderer
● Represents tools for drawing like rectangle, line
of text, image or just a line
● Common properties & styles like top, width,
zIndex, height, backgroundColor are expressed
using Layer Component
Why you should use react canvas
Group Components
● It allows to group several primitive components
together
● It’s a container component
● It allows rendering to cache expensive drawing
operations
Why you should use react canvas
Bridge Or Surface Component
● Entry point into your application
● React component that renders the canvas
Why you should use react canvas
Limitations of React Canvas
● Doesn’t support responsive web design
● If not designed properly, can cause huge memory leaks
Alternative libraries
● React Konva
○ https://github.com/lavrton/react-konva
● Pabla
○ https://github.com/goshakkk/pabla
Thank You

More Related Content

PDF
Thinking cpu & memory - DroidCon Paris 18 june 2013
PDF
Hack SAPUI5 libraries with Grunt
PDF
Ask the expert - App performance on Series 40 phones
PPT
Performance-driven front-end development
PDF
Qt and QML performance tips & tricks for Qt 4.7
PDF
Gatling - Bordeaux JUG
PPTX
React Fiber
PDF
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
Thinking cpu & memory - DroidCon Paris 18 june 2013
Hack SAPUI5 libraries with Grunt
Ask the expert - App performance on Series 40 phones
Performance-driven front-end development
Qt and QML performance tips & tricks for Qt 4.7
Gatling - Bordeaux JUG
React Fiber
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020

Similar to Why you should use react canvas (20)

PDF
Designing and coding Series 40 Java apps for high performance
PDF
Software Profiling: Java Performance, Profiling and Flamegraphs
PDF
Large-Scale, Semi-Automated Go Garbage Collection Tuning at Uber
PDF
Multi screenlab
PDF
High performance in react native
PDF
Running HTML5 Mobile Web Games at 60fps
PDF
State And Ajax Zend Con
PDF
Real-time Stream Processing using Apache Apex
PDF
Introduction to Apache Apex - CoDS 2016
PPTX
PDF
Using PhantomJS to keep product screenshots up to date
PPT
EXT_window_rectangles
PDF
Hacking to be performant
PDF
The Power of WebGL - Hackeando sua GPU com JavaScript
PDF
Dev tools rendering & memory profiling
PDF
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
PPTX
Caching Tips & Tricks
PDF
PyGrunn2013 High Performance Web Applications with TurboGears
PDF
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016
PDF
OpenLayers 3.0
Designing and coding Series 40 Java apps for high performance
Software Profiling: Java Performance, Profiling and Flamegraphs
Large-Scale, Semi-Automated Go Garbage Collection Tuning at Uber
Multi screenlab
High performance in react native
Running HTML5 Mobile Web Games at 60fps
State And Ajax Zend Con
Real-time Stream Processing using Apache Apex
Introduction to Apache Apex - CoDS 2016
Using PhantomJS to keep product screenshots up to date
EXT_window_rectangles
Hacking to be performant
The Power of WebGL - Hackeando sua GPU com JavaScript
Dev tools rendering & memory profiling
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Caching Tips & Tricks
PyGrunn2013 High Performance Web Applications with TurboGears
Alex_Vlachos_Advanced_VR_Rendering_Performance_GDC2016
OpenLayers 3.0
Ad

Recently uploaded (20)

PPT
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PDF
737-MAX_SRG.pdf student reference guides
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
introduction to high performance computing
PDF
Soil Improvement Techniques Note - Rabbi
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PPT
Total quality management ppt for engineering students
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
737-MAX_SRG.pdf student reference guides
Fundamentals of Mechanical Engineering.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
introduction to high performance computing
Soil Improvement Techniques Note - Rabbi
III.4.1.2_The_Space_Environment.p pdffdf
Visual Aids for Exploratory Data Analysis.pdf
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Total quality management ppt for engineering students
Ad

Why you should use react canvas

  • 1. Why you should use React Canvas
  • 2. Arwa Lokhandwala Senior Full Stack Developer @BookMyShow @arwa1893
  • 3. Agenda ● The Jank problem ● Why the Jank happens ● Understanding the Rendering process ● How to optimize scrolling performance ● Knowing the React-canvas ● How react canvas actually works ● Limitations of React-canvas ● Alternative libraries ● Demo
  • 4. The Jank problem “Jank” is any stuttering or choppiness that a user experiences when there is motion on the screen—like during scrolling, transitions, or animations.
  • 5. Why the Jank happens ??? ● Most of the devices refresh their screens 60 times a second ● The browser needs to match the device’s refresh rate and put up 1 new picture, or frame, for each of those screen refreshes. ● Each frame has a budget of 1000/60 = 16.66 ms
  • 6. Understanding the Rendering Process 1. Calculate 2. Layout 3. Paint 4. Composite
  • 7. Optimizing scrolling performance ● Avoid Expensive Styles ● Keep Reflows and Repaints to minimum ( Ex : offsetTop property) ● Debounce your scroll events
  • 8. React Canvas Adds the ability to react components to render to canvas rather than the DOM
  • 9. Bridge or Surface Component Group Component Primitive Component Primitive Component How react canvas actually works
  • 10. Primitive Component & Layer component ● Basic building blocks of your custom renderer ● Represents tools for drawing like rectangle, line of text, image or just a line ● Common properties & styles like top, width, zIndex, height, backgroundColor are expressed using Layer Component
  • 12. Group Components ● It allows to group several primitive components together ● It’s a container component ● It allows rendering to cache expensive drawing operations
  • 14. Bridge Or Surface Component ● Entry point into your application ● React component that renders the canvas
  • 16. Limitations of React Canvas ● Doesn’t support responsive web design ● If not designed properly, can cause huge memory leaks
  • 17. Alternative libraries ● React Konva ○ https://github.com/lavrton/react-konva ● Pabla ○ https://github.com/goshakkk/pabla

Editor's Notes

  • #5: We all know CSS animations and transitions are the fastest path to smooth animations on the web but we are frustrated with the fact that it feels slow when compared to the native apps. It is linked to how smoothly your page renders So the lag which the users experience while he touches the screen and when the page responds is called a Jank
  • #6: Jank is simply the result of the web page not being able to keep up with the refresh rate of the display
  • #7: Calculate - Determines which CSS rules apply to which elements Layout - Determines dimensions and positions for each element Paint - Fills in the pixels for each element onto layers, but doesn’t yet draw these layers screen Composite - Draws the painted layers to screen Each of these steps triggers those steps that comes after it and not vice versa So in order to improve the rendering performance of our page, we have to make sure that the browser performs minimum of the above steps
  • #8: Avoid expensive styling - some styles are expensive because they require repainting example - top, left properties causes the browser to again perform the layout, paint and then the composite step which is pretty expensive, so we should avoid using such styles and replace it with styles that triggers only the final composite step like transform: translateY(-100px). Similar thing goes for box-shadow Whenever you try n use offsetTop property, it immediately gives the browser alot of work because it now has to go and layout your page to give the correct answer, this is what is called reflowing and then if you try to change the property of another element then browser has to do the repainting again, this repaint reflow cycle should be avoided…..Use requestAnimationFrames instead. -------Before moving to the next slide say this -------------------- We all know most of the modern browsers today have hardware accelerated canvas. React Canvas basically leverages this fact
  • #9: React Canvas brings some of the APIs web developers are familiar with and blends them with a high performance drawing engine.
  • #10: React canvas provides a set of Standard React Components that abstracts the underlying rendering implementation
  • #13: Primitive elements like line, Image, rectangle Because reacts wants all the child components to rendered with in a single element Hence it optimizes the scrolling performance
  • #15: Bridge or Surface components can be thought of as a drawing canvas on which you place your other components Its a top level component which encompasses your entire application