From f69153f25cfd9905b1de0a6c39cd776e06e3a8ec Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 17 Feb 2025 05:18:46 -0800 Subject: [PATCH 1/2] RNGP - Add option to disable bundle compression (was: Make all React Native apps start 12% faster) (#49449) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Okay the title is a bit clickbaity, but this is actually true. (on Android) We (Janic, Szymon, Ruby and Me) discovered something interesting. React Native uses `mmap` for mapping the JS bundle to RAM, to avoid having to load the entire thing instantly at app startup. Ruby doubted that this was true - so we investigated. Apparently on Android, resources are **compressed**. And if the JS bundle is stored compressed, it has to be uncompressed before it can be loaded into RAM, hence not allowing it to be mmapp'ed! (see [`_CompressedAsset::getBuffer`](https://cs.android.com/android/platform/superproject/+/master:frameworks/base/libs/androidfw/Asset.cpp;l=903?q=Asset.cpp)) So with this PR, we now add `.bundle` files to `noCompress` in the react-native gradle plugin, which disables compression for the JS bundle. In our tests, **this improved TTI by 400ms!! (or 12%)** 🤯🚀 NOTE: Yes, the .apk will now be bigger. But; Google Play compresses it anyways, so the **download size** of your .apk will likely not increase by much. It will be bigger on disk though. ## Changelog: [ANDROID] [CHANGED] Add option to disable bundle compression to improve startup time + + + - - - - + + + + - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/AppTheme"> + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings.gradle.kts b/settings.gradle.kts index 4a6e16a5aeaa..8d22d7f38c63 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,3 +39,5 @@ configure { autolinkLibrariesFromCommand( workingDirectory = file("packages/rn-tester/"), lockFiles = files("yarn.lock")) } + +include(":packages:rn-tester:android:app:benchmark")