Flashlight, a Lighthouse for Mobile Apps

Rate this content
Bookmark

The promise of Lighthouse is pretty cool, right? Visit any website, and with only a few clicks, you can get a performance score for it!

Wouldn’t it be grand if we had the same thing for React Native apps? 


Well, you’re in luck! let me present our new open source tool called Flashlight 🔦 

(cause you know, a Flashlight is basically a very small “mobile” lighthouse, right?)

This talk has been presented at React Advanced 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

Yes, Flashlight can be used locally with its open-source CLI. You can install it and use it to measure performance changes in your app on a connected device.

By default, Flashlight runs on a real low-end Android device, specifically a Samsung Galaxy A10s.

You can contact Alex on Twitter or GitHub for any additional questions about Flashlight.

Flashlight measures various performance metrics including app start performance, CPU usage, frame rates, and CPU usage per thread.

The JS thread is responsible for running JavaScript code in your app. High CPU usage on the JS thread can lead to poor app performance, such as unresponsive UI and low frame rates.

You can upload an Android app to Flashlight by visiting app.flashlight.dev, generating a release APK of your app, and configuring the performance metrics you want to measure.

You can find more information about Flashlight in its documentation at docs.flashlight.dev or by reading related articles, such as the one comparing list scrolling performance between FlatList and FlashList.

It takes roughly 10 minutes for Flashlight to generate a performance report, depending on traffic.

Flashlight is a new performance measurement tool for mobile apps, similar to Lighthouse for web pages. It allows users to upload an Android app and generate a performance report.

You can improve your app's performance by analyzing the metrics provided in the Flashlight report and making necessary changes. For example, switching from FlatList to FlashList improved the performance of a sample app.

Alexandre Moureaux
Alexandre Moureaux
7 min
23 Oct, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Today's Talk introduces Flashlight, a tool for measuring mobile app performance. Flashlight provides a performance report that highlights issues like high CPU usage on low-end devices. To fix these issues, the Shopify component Flashlist can be used. Flashlight can also be used locally to measure performance changes in React Native apps, with the ability to see the score rapidly changing and improved performance after implementing fixes. More information can be found in the documentation and an article comparing scrolling performance in React Native.

1. Introduction to Flashlight

Short description:

Hi, everyone. Today, I'm happy to talk about measuring mobile app performance and introduce our new tool called Flashlight. It's like a mobile Lighthouse. Just upload your Android app on app.flashlight.dev, configure the measurement, and get a performance report.

Hi, everyone. I'm Alex. I've been working with React Native for the past eight years at BAM, and today I'm very happy to talk to you about measuring mobile app's performance. I've always wanted to have an easy way to know whether the performance of my app was good or not. And I've always been jealous of web developers for Lighthouse. Have you ever used Lighthouse? You can go to any website and with it, with a simple few clicks, just generate a performance report and get a performance score for the web page you visited, which is pretty neat, right?

Wouldn't it be nice if we had something similar, but for mobile apps? Well, today I'm very proud to present you our new tool called Flashlight. It's meant as a mobile Lighthouse. So let's see how it works. You can go right now, if you like, on app.flashlight.dev and upload any Android app, iOS support is on the way. So let's say, for example, this is sharing my phone. We have an app like this, like I have sort of a Netflix clone. I can generate a release APK for it and upload it right here. And then I can configure what I want Flashlight to measure. So by default, you can measure app start performance quite easily. You just need to input here some text that will appear when the app has loaded. For example, here when my app has loaded, I know that family and history will appear so I can just input family here, and then click send me my performance report.

2. Analyzing Performance Report and Fixing Issues

Short description:

Now a new page opens, and after roughly 10 minutes, Flashlight provides a performance report. We can see that the app has high CPU usage, particularly in the JS Thread. This issue is highlighted by Flashlight, especially on low-end devices. To fix it, we can switch to using the Shopify component called Flashlist, which significantly improves performance.

Now a new page opens, depending on traffic, it should take roughly 10 minutes to finish and Flashlight to get the report. So I'm going to split this up a little bit. So when Flashlight is finally done, after roughly 10 minutes, this is what you would see. You would see that essentially what happened is that Flashlight has started the app 10 times and measured performance and what's really nice is that you have this see report button and if you click it, boom, you have your performance report. And in our case, we can see that it's pretty bad. Luckily, Flashlight gives us some performance metrics to understand why it's that bad.

Here we can see, for example, that this one here is the one that seems to be problematic. High CPU usage. We see that we have a thread using a lot of CPU for a lot of time, a thread called mqtjs. We can check the graphs. So we have frame rates, we have total CPU usage and we have CPU usage per thread and we can see again mqtjs in fact, basically for the whole duration of measure it's really really high. It uses way too much CPU. Okay, we can ask ourselves, what is mqtjs? You guessed it, it's the JS Thread. You never want this guy to be close to 100% of CPU usage because then that's the same as having zero JSFPS, your app would not respond to anything. The JS Thread is blocked. So, that's what happens when we open our app, basically, and flashlight is telling us we have a big issue. Note that actually Flashlight is running on a real low-end android device, a Samsung Galaxy A10s by default. So on a low-end device yeah, performance is really bad. What can we do to fix? Well, our app is basically a vertical list composed of horizontal nested lists. And we're using flat lists for both of those, horizontal and vertical. But let's see what happens if we change to using the Shopify component called Flashlist. Then we can just regenerate our APK and do exactly the same thing as before to get a new report with Flashlist. And boom! Ah, this is much better. We get a score of 75 out of 100. But what's really nice is we can actually go onto the history section here. We can click both reports, so the first one, MyAppWithFlatlist and the second one called Flashlist. And we can open the comparison view. We have the video as well. I'm just going to close them. And for example, if I jump to the CPU usage per thread, we can see quite easily that yeah, in green with Flashlist, CPU usage of the Jez thread is in fact much better with Flashlist.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Guide to React Rendering Behavior
React Advanced 2022React Advanced 2022
25 min
A Guide to React Rendering Behavior
Top Content
This transcription provides a brief guide to React rendering behavior. It explains the process of rendering, comparing new and old elements, and the importance of pure rendering without side effects. It also covers topics such as batching and double rendering, optimizing rendering and using context and Redux in React. Overall, it offers valuable insights for developers looking to understand and optimize React rendering.
Speeding Up Your React App With Less JavaScript
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Top Content
Watch video: Speeding Up Your React App With Less JavaScript
Mishko, the creator of Angular and AngularJS, discusses the challenges of website performance and JavaScript hydration. He explains the differences between client-side and server-side rendering and introduces Quik as a solution for efficient component hydration. Mishko demonstrates examples of state management and intercommunication using Quik. He highlights the performance benefits of using Quik with React and emphasizes the importance of reducing JavaScript size for better performance. Finally, he mentions the use of QUIC in both MPA and SPA applications for improved startup performance.
React Concurrency, Explained
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
Top Content
Watch video: React Concurrency, Explained
React 18's concurrent rendering, specifically the useTransition hook, optimizes app performance by allowing non-urgent updates to be processed without freezing the UI. However, there are drawbacks such as longer processing time for non-urgent updates and increased CPU usage. The useTransition hook works similarly to throttling or bouncing, making it useful for addressing performance issues caused by multiple small components. Libraries like React Query may require the use of alternative APIs to handle urgent and non-urgent updates effectively.
The Future of Performance Tooling
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Today's Talk discusses the future of performance tooling, focusing on user-centric, actionable, and contextual approaches. The introduction highlights Adi Osmani's expertise in performance tools and his passion for DevTools features. The Talk explores the integration of user flows into DevTools and Lighthouse, enabling performance measurement and optimization. It also showcases the import/export feature for user flows and the collaboration potential with Lighthouse. The Talk further delves into the use of flows with other tools like web page test and Cypress, offering cross-browser testing capabilities. The actionable aspect emphasizes the importance of metrics like Interaction to Next Paint and Total Blocking Time, as well as the improvements in Lighthouse and performance debugging tools. Lastly, the Talk emphasizes the iterative nature of performance improvement and the user-centric, actionable, and contextual future of performance tooling.
Optimizing HTML5 Games: 10 Years of Learnings
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Optimizing HTML5 Games: 10 Years of Learnings
Top Content
Watch video: Optimizing HTML5 Games: 10 Years of Learnings
PlayCanvas is an open-source game engine used by game developers worldwide. Optimization is crucial for HTML5 games, focusing on load times and frame rate. Texture and mesh optimization can significantly reduce download sizes. GLTF and GLB formats offer smaller file sizes and faster parsing times. Compressing game resources and using efficient file formats can improve load times. Framerate optimization and resolution scaling are important for better performance. Managing draw calls and using batching techniques can optimize performance. Browser DevTools, such as Chrome and Firefox, are useful for debugging and profiling. Detecting device performance and optimizing based on specific devices can improve game performance. Apple is making progress with WebGPU implementation. HTML5 games can be shipped to the App Store using Cordova.
How React Compiler Performs on Real Code
React Advanced 2024React Advanced 2024
31 min
How React Compiler Performs on Real Code
Top Content
I'm Nadia, a developer experienced in performance, re-renders, and React. The React team released the React compiler, which eliminates the need for memoization. The compiler optimizes code by automatically memoizing components, props, and hook dependencies. It shows promise in managing changing references and improving performance. Real app testing and synthetic examples have been used to evaluate its effectiveness. The impact on initial load performance is minimal, but further investigation is needed for interactions performance. The React query library simplifies data fetching and caching. The compiler has limitations and may not catch every re-render, especially with external libraries. Enabling the compiler can improve performance but manual memorization is still necessary for optimal results. There are risks of overreliance and messy code, but the compiler can be used file by file or folder by folder with thorough testing. Practice makes incredible cats. Thank you, Nadia!

Workshops on related topic

React Performance Debugging Masterclass
React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured WorkshopFree
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Building WebApps That Light Up the Internet with QwikCity
JSNation 2023JSNation 2023
170 min
Building WebApps That Light Up the Internet with QwikCity
Featured WorkshopFree
Miško Hevery
Miško Hevery
Building instant-on web applications at scale have been elusive. Real-world sites need tracking, analytics, and complex user interfaces and interactions. We always start with the best intentions but end up with a less-than-ideal site.
QwikCity is a new meta-framework that allows you to build large-scale applications with constant startup-up performance. We will look at how to build a QwikCity application and what makes it unique. The workshop will show you how to set up a QwikCitp project. How routing works with layout. The demo application will fetch data and present it to the user in an editable form. And finally, how one can use authentication. All of the basic parts for any large-scale applications.
Along the way, we will also look at what makes Qwik unique, and how resumability enables constant startup performance no matter the application complexity.
Introducing FlashList: Let's build a performant React Native list all together
React Advanced 2022React Advanced 2022
81 min
Introducing FlashList: Let's build a performant React Native list all together
Top Content
WorkshopFree
David Cortés Fulla
Marek Fořt
Talha Naqvi
3 authors
In this workshop you’ll learn why we created FlashList at Shopify and how you can use it in your code today. We will show you how to take a list that is not performant in FlatList and make it performant using FlashList with minimum effort. We will use tools like Flipper, our own benchmarking code, and teach you how the FlashList API can cover more complex use cases and still keep a top-notch performance.You will know:- Quick presentation about what FlashList, why we built, etc.- Migrating from FlatList to FlashList- Teaching how to write a performant list- Utilizing the tools provided by FlashList library (mainly the useBenchmark hook)- Using the Flipper plugins (flame graph, our lists profiler, UI & JS FPS profiler, etc.)- Optimizing performance of FlashList by using more advanced props like `getType`- 5-6 sample tasks where we’ll uncover and fix issues together- Q&A with Shopify team
Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
WorkshopFree
Alice De Mauro
Alice De Mauro
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
Detox 101: How to write stable end-to-end tests for your React Native application
React Summit 2022React Summit 2022
117 min
Detox 101: How to write stable end-to-end tests for your React Native application
Top Content
WorkshopFree
Yevheniia Hlovatska
Yevheniia Hlovatska
Compared to unit testing, end-to-end testing aims to interact with your application just like a real user. And as we all know it can be pretty challenging. Especially when we talk about Mobile applications.
Tests rely on many conditions and are considered to be slow and flaky. On the other hand - end-to-end tests can give the greatest confidence that your app is working. And if done right - can become an amazing tool for boosting developer velocity.
Detox is a gray-box end-to-end testing framework for mobile apps. Developed by Wix to solve the problem of slowness and flakiness and used by React Native itself as its E2E testing tool.
Join me on this workshop to learn how to make your mobile end-to-end tests with Detox rock.
Prerequisites- iOS/Android: MacOS Catalina or newer- Android only: Linux- Install before the workshop
How to Build an Interactive “Wheel of Fortune” Animation with React Native
React Summit Remote Edition 2021React Summit Remote Edition 2021
60 min
How to Build an Interactive “Wheel of Fortune” Animation with React Native
Top Content
Workshop
Oli Bates
Oli Bates
- Intro - Cleo & our mission- What we want to build, how it fits into our product & purpose, run through designs- Getting started with environment set up & “hello world”- Intro to React Native Animation- Step 1: Spinning the wheel on a button press- Step 2: Dragging the wheel to give it velocity- Step 3: Adding friction to the wheel to slow it down- Step 4 (stretch): Adding haptics for an immersive feel