Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Desktop Applications with Electron

Desktop Applications with Electron

Electron is the technology used to build popular cross-platform desktop applications such as Atom, Slack, Visual Studio Code and Skype. However it suffers from a bad reputation with the community: memory and performance issues, non-native look and feel.
This presentation aims to demystify some of this bad reputation. What is Electron, when to use it, some code samples to get you started and how can we make high performance applications with it.

Examples: https://github.com/jportela/electron-presentation-examples

João Portela

December 20, 2018
Tweet

Other Decks in Programming

Transcript

  1. AGENDA ▸ What is Electron? ▸ When to use Electron?

    ▸ Getting Started with Electron ▸ Deep Dive into Electron ▸ High Performance Electron DESKTOP APPLICATIONS WITH ELECTRON
  2. WHAT IS ELECTRON? CONTEXT The Web Platform Atom "Zero-compromise combination

    of HACKABILITY and USABILITY" https://flight-manual.atom.io/getting-started/sections/why-atom/
  3. WHAT IS ELECTRON? INSIDE ELECTRON Chromium ‣ Node APIs ‣

    C++ Integration ‣ Module System ‣ Browser Window
  4. WHAT IS ELECTRON? ELECTRON ‣ Automatic Updates ‣ Native Menus

    ‣ Native Notifications ‣ Crash Reporting ‣ Debugging & Profiling ‣ Windows Installer
  5. WHEN TO USE ELECTRON? ELECTRON'S WEAKNESSES ‣ App Size (>100MB

    uncompressed) ‣ Memory ‣ Performance ‣ Look and Feel
  6. WHEN TO USE ELECTRON? ELECTRON'S STRENGTHS ‣ Cross Platform ‣

    One Platform ‣ Web Technologies ‣ Community ‣ Developer Experience
  7. WHEN TO USE ELECTRON? IT'S ALL ABOUT TRADE OFFS ‣

    App Size ‣ Cross Platform ‣ Productivity ‣ Value
  8. PREREQUISITES (FOR UNDERSTANDING DEMOS) ▸ ES 2017 (or ES 2015

    + async/await) ▸ Basic Node ▸ Basic Web Development GETTING STARTED WITH ELECTRON
  9. MAIN PROCESS ▸ Orchestrates Browser Windows ▸ Electron APIs for

    deeper OS integration ▸ Node environment ▸ No Browser APIs / DOM DEEP DIVE INTO ELECTRON
  10. RENDERER PROCESS ▸ Spawned from the Main Process ▸ Browser

    APIs / DOM ▸ Node environment DEEP DIVE INTO ELECTRON
  11. IMAGE VIEWER EXAMPLE DEEP DIVE INTO ELECTRON ▸ Show JPEGs

    from a selected directory ▸ System Menu ▸ Multiple Windows
  12. DEMO TIME DEEP DIVE INTO ELECTRON ▸ https://github.com/jportela/electron-presentation- examples ▸

    /image-viewer ▸ Electron APIs: BrowserWindow, Menu, dialog ▸ NodeJS APIs: fs, path, util ▸ Electron IPC
  13. PROFILING ▸ Manually use Chrome's Profiling Tools ▸ Automatically: https://electronjs.org/docs/api/content-

    tracing ▸ Stats.js FPS Counter: https://github.com/mrdoob/stats.js/ ▸ Demo HIGH PERFORMANCE ELECTRON
  14. PROFILING RESULTS ▸ Loading image buffer using readFile ▸ Rendering

    the image using the rasterizer HIGH PERFORMANCE ELECTRON
  15. CPU INTENSIVE PROCESSING ▸ Web Workers ▸ Background Browser Window

    ▸ Node Process ▸ C++ Native Module ▸ Web Assembly HIGH PERFORMANCE ELECTRON
  16. INTER PROCESS COMMUNICATION ▸ Electron IPC ▸ Slow for large

    payloads ▸ Can potentially block GPU (see https://github.com/ electron/electron/issues/12098) ▸ Unix/Windows Sockets ▸ ZeroMQ or other IPC solutions HIGH PERFORMANCE ELECTRON
  17. GENERAL TIPS ▸ Profiling ▸ Web Performance Practices ▸ Bundling

    ▸ C++ Native Modules ▸ Web Assembly ▸ Canvas/WebGL HIGH PERFORMANCE ELECTRON
  18. Q&A