Flashlight, un Faro para Aplicaciones Móviles

Rate this content
Bookmark

La promesa de Lighthouse es bastante genial, ¿verdad? Visita cualquier sitio web, y con solo unos pocos clics, ¡puedes obtener una puntuación de rendimiento para él!

¿No sería grandioso si tuviéramos lo mismo para las aplicaciones React Native?


¡Pues estás de suerte! Permíteme presentarte nuestra nueva herramienta de código abierto llamada Flashlight 🔦

(porque ya sabes, una linterna es básicamente un faro “móvil” muy pequeño, ¿verdad?)

Alexandre Moureaux
Alexandre Moureaux
7 min
23 Oct, 2023

Video Summary and Transcription

La charla de hoy presenta Flashlight, una herramienta para medir el rendimiento de las aplicaciones móviles. Flashlight proporciona un informe de rendimiento que destaca problemas como el alto uso de CPU en dispositivos de gama baja. Para solucionar estos problemas, se puede utilizar el componente Flashlist de Shopify. Flashlight también se puede utilizar localmente para medir los cambios de rendimiento en las aplicaciones React Native, con la capacidad de ver la puntuación cambiando rápidamente y el rendimiento mejorado después de implementar las correcciones. Se puede encontrar más información en la documentación y en un artículo que compara el rendimiento de desplazamiento en React Native.

Available in English

1. Introducción a Flashlight

Short description:

Hola a todos. Hoy, estoy feliz de hablar sobre la medición del rendimiento de las aplicaciones móviles e introducir nuestra nueva herramienta llamada Flashlight. Es como un Lighthouse móvil. Solo sube tu aplicación Android en app.flashlight.dev, configura la medición y obtén un informe de rendimiento.

Hola a todos. Soy Alex. He estado trabajando con React Native durante los últimos ocho años en BAM, y hoy estoy muy feliz de hablarles sobre la medición del rendimiento de las aplicaciones móviles. Siempre he querido tener una forma fácil de saber si el rendimiento de mi aplicación era bueno o no. Y siempre he estado celoso de los desarrolladores web por Lighthouse. ¿Alguna vez has usado Lighthouse? Puedes ir a cualquier sitio web y con él, con unos pocos clics, simplemente generar un informe de rendimiento y obtener una puntuación de rendimiento para la página web que visitaste, lo cual es bastante genial, ¿verdad? ¿No sería agradable si tuviéramos algo similar, pero para aplicaciones móviles? Bueno, hoy estoy muy orgulloso de presentarles nuestra nueva herramienta llamada Flashlight. Está pensada como un Lighthouse móvil. Así que veamos cómo funciona. Puedes ir ahora mismo, si quieres, a app.flashlight.dev y subir cualquier aplicación Android, el soporte para iOS está en camino. Así que digamos, por ejemplo, esto es compartir mi teléfono. Tenemos una aplicación como esta, como tengo una especie de clon de Netflix. Puedo generar un APK de lanzamiento para él y subirlo aquí mismo. Y luego puedo configurar lo que quiero que Flashlight mida. Así que por defecto, puedes medir el inicio de la aplicación bastante fácilmente. Solo necesitas introducir aquí algún texto que aparecerá cuando la aplicación se haya cargado. Por ejemplo, aquí cuando mi aplicación se ha cargado, sé que familia e historia aparecerán así que puedo simplemente introducir familia aquí, y luego hacer clic en envíame mi rendimiento

2. Análisis del Informe de Rendimiento y Solución de Problemas

Short description:

Ahora se abre una nueva página y, después de aproximadamente 10 minutos, Flashlight proporciona un informe de rendimiento. Podemos ver que la aplicación tiene un alto uso de CPU, particularmente en el Hilo JS. Flashlight destaca este problema, especialmente en dispositivos de gama baja. Para solucionarlo, podemos cambiar a usar el componente de Shopify llamado Flashlist, que mejora significativamente el rendimiento.

informe. Ahora se abre una nueva página, dependiendo del tráfico, debería tomar aproximadamente 10 minutos para terminar y que Flashlight obtenga el informe. Así que voy a dividir esto un poco. Entonces, cuando Flashlight finalmente termina, después de aproximadamente 10 minutos, esto es lo que verías. Verías que esencialmente lo que sucedió es que Flashlight ha iniciado la aplicación 10 veces y ha medido performance y lo que es realmente agradable es que tienes este botón de ver informe y si haces clic en él, boom, tienes tu informe de performance. Y en nuestro caso, podemos ver que es bastante malo. Afortunadamente, Flashlight nos da algunas métricas de performance para entender por qué es tan malo. Aquí podemos ver, por ejemplo, que este aquí es el que parece ser problemático. Alto uso de CPU. Vemos que tenemos un hilo usando mucha CPU durante mucho tiempo, un hilo llamado mqtjs. Podemos revisar los gráficos. Así que tenemos tasas de fotogramas, tenemos el uso total de CPU y tenemos el uso de CPU por hilo y podemos ver de nuevo mqtjs de hecho, básicamente durante toda la duración de la medida es realmente muy alto. Utiliza demasiada CPU. Bueno, podemos preguntarnos, ¿qué es mqtjs? Lo adivinaste, es el Hilo JS. Nunca quieres que este tipo esté cerca del 100% de uso de CPU porque entonces eso es lo mismo que tener cero JSFPS, tu aplicación no respondería a nada. El Hilo JS está bloqueado. Entonces, eso es lo que sucede cuando abrimos nuestra aplicación, básicamente, y Flashlight nos está diciendo que tenemos un gran problema. Ten en cuenta que en realidad Flashlight se está ejecutando en un verdadero dispositivo Android de gama baja, un Samsung Galaxy A10s por defecto. Así que en un dispositivo de gama baja sí, performance es realmente mala. ¿Qué podemos hacer para solucionarlo? Bueno, nuestra aplicación es básicamente una lista vertical compuesta de listas horizontales anidadas. Y estamos usando flat lists para ambas, horizontal y vertical. Pero veamos qué sucede si cambiamos a usar el componente de Shopify llamado Flashlist. Luego podemos simplemente regenerar nuestro APK y hacer exactamente lo mismo que antes para obtener un nuevo informe con Flashlist. ¡Y boom! Ah, esto es mucho mejor. Obtenemos una puntuación de 75 de 100. Pero lo que es realmente agradable es que podemos ir a la sección de historial aquí. Podemos hacer clic en ambos informes, el primero, MyAppWithFlatlist y el segundo llamado Flashlist. Y podemos abrir la vista de comparación. Tenemos el video también. Solo voy a cerrarlos. Y por ejemplo, si salto al uso de CPU por hilo, podemos ver bastante fácilmente que sí, en verde con Flashlist, el uso de CPU del hilo Jez es

3. Uso de Flashlight para la Medición Local del Rendimiento

Short description:

Con Flashlight, puedes medir los cambios de rendimiento en tu aplicación utilizando nuestra interfaz de línea de comandos (CLI) de código abierto. Instálalo fácilmente y ejecuta 'Flashlight measure' en tu dispositivo conectado con una aplicación React Native. Comienza a medir el rendimiento del desplazamiento y observa cómo la puntuación cambia rápidamente. Si hay un problema en el hilo JS, implementa una solución como cambiar a Flashlist. Recarga y mide de nuevo para ver un rendimiento mejorado. Para obtener más información, consulta la documentación en docs.flashlight.dev o un artículo que compara el rendimiento del desplazamiento de la lista en React Native entre FlatList y FlashList. No dudes en ponerte en contacto a través de Twitter o GitHub si tienes alguna pregunta.

de hecho, mucho mejor con Flashlist. Pero lo bueno de Flashlight es que también puedes usarlo localmente para medir rápidamente los cambios de rendimiento en tu aplicación con nuestra CLI de código abierto. Es muy sencillo de instalar. Y luego, por ejemplo, si tienes un dispositivo conectado con una aplicación React Native en ejecución, puedes simplemente ejecutar Flashlight measure. Luego auto detect para detectar automáticamente la aplicación que está actualmente en foco. Y digamos que quiero medir el rendimiento del desplazamiento. Puedo empezar a medir. Comienzo a desplazarme en mi aplicación. Y medirá el rendimiento de este desplazamiento. Puedes ver que la puntuación cambia rápidamente a cero. De nuevo, tenemos un problema masivo en el hilo JS al desplazarse. Así que digamos que implementaste una solución. Por ejemplo, cambiando de flat list a flash list. Podemos recargar. Y básicamente podemos hacer lo mismo de nuevo. Empecemos a medir de nuevo. Desplázate de nuevo. Y podemos ver que ahora, el rendimiento es realmente mucho mejor. Eso es todo para esta breve presentación de Flashlight. Si quieres saber más sobre lo que puede hacer, puedes consultar la documentación en docs.flashlight.dev o también puedes consultar este artículo sobre la comparación del rendimiento del desplazamiento de la lista en una aplicación React Native entre FlatList y FlashList, que entra en más detalles. De lo contrario, si tienes alguna pregunta también puedes contactarme en Twitter o GitHub. En cualquier caso, espero que hayas disfrutado de la presentación y que tengas un buen tiempo.

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 Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
React is a library for "rendering" UI from components, but many users find themselves confused about how React rendering actually works. What do terms like "rendering", "reconciliation", "Fibers", and "committing" actually mean? When do renders happen? How does Context affect rendering, and how do libraries like Redux cause updates? In this talk, we'll clear up the confusion and provide a solid foundation for understanding when, why, and how React renders. We'll look at: - What "rendering" actually is - How React queues renders and the standard rendering behavior - How keys and component types are used in rendering - Techniques for optimizing render performance - How context usage affects rendering behavior| - How external libraries tie into 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
Too much JavaScript is getting you down? New frameworks promising no JavaScript look interesting, but you have an existing React application to maintain. What if Qwik React is your answer for faster applications startup and better user experience? Qwik React allows you to easily turn your React application into a collection of islands, which can be SSRed and delayed hydrated, and in some instances, hydration skipped altogether. And all of this in an incremental way without a rewrite.
React Concurrency, Explained
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
Top Content
React 18! Concurrent features! You might’ve already tried the new APIs like useTransition, or you might’ve just heard of them. But do you know how React 18 achieves the performance wins it brings with itself? In this talk, let’s peek under the hood of React 18’s performance features: - How React 18 lowers the time your page stays frozen (aka TBT) - What exactly happens in the main thread when you run useTransition() - What’s the catch with the improvements (there’s no free cake!), and why Vue.js and Preact straight refused to ship anything similar
The Future of Performance Tooling
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Our understanding of performance & user-experience has heavily evolved over the years. Web Developer Tooling needs to similarly evolve to make sure it is user-centric, actionable and contextual where modern experiences are concerned. In this talk, Addy will walk you through Chrome and others have been thinking about this problem and what updates they've been making to performance tools to lower the friction for building great experiences on the web.
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
The open source PlayCanvas game engine is built specifically for the browser, incorporating 10 years of learnings about optimization. In this talk, you will discover the secret sauce that enables PlayCanvas to generate games with lightning fast load times and rock solid frame rates.
When Optimizations Backfire
JSNation 2023JSNation 2023
26 min
When Optimizations Backfire
Top Content
Ever loaded a font from the Google Fonts CDN? Or added the loading=lazy attribute onto an image? These optimizations are recommended all over the web – but, sometimes, they make your app not faster but slower.
In this talk, Ivan will show when some common performance optimizations backfire – and what we need to do to avoid that.

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.
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
Introducing FlashList: Let's build a performant React Native list all together
React Advanced Conference 2022React Advanced Conference 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
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