Skip to content

feat(android): Automatically call FullyDrawnReporter to improve production PGOs - #57799

Open
mrousavy wants to merge 1 commit into
react:mainfrom
mrousavy:feat/reportfullydrawn
Open

feat(android): Automatically call FullyDrawnReporter to improve production PGOs#57799
mrousavy wants to merge 1 commit into
react:mainfrom
mrousavy:feat/reportfullydrawn

Conversation

@mrousavy

@mrousavy mrousavy commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary:

Since Android 12 the Google PlayStore automatically profiles cold starts of new apps on user devices to optimize them for subsequent launches (affects JVM, not native).

This works most effectively if the app reliably calls reportFullyDrawn() once its content has been... fully drawn.

See App startup time: Android Vitals for more information

This is super hard to test isolated, but it should improve performance in production by making these PlayStore profiles more accurate, allowing Android to optimize production apps better as it understands when TTFD (Time-To-Full-Display) actually happens, which is hard to tell for Android in a non-native Android app (i.e. react-native, with asynchronous rendering and whatnot).

Since react-native renders the main UI asynchronously, I do expect this change to make a performance difference in production, but this is merely an assumption and not a tested claim.

Btw., this does not call reportFullyDrawn() directly, but instead uses androidx' FullyDrawnReporter, which is collaborative - meaning this works well in brownfield apps and apps can also extend this to register their reporter to delay their TTFD reporting.

By default, it is enabled and reports on CONTENT_APPEARED.

I added a feature flag which allows users (brownfield?) to disable it by overriding isFullyDrawnReportingEnabled() to return false.

Changelog:

[ANDROID] [ADDED] - Automatically call FullyDrawnReporter to improve production performance via profiles

Test Plan:

Isolated

Make sure reportFullyDrawn() is called:

adb logcat -s ActivityTaskManager

Before this PR you'll see something like

Displayed com.app/.MainActivity: +400ms

After this PR you'll see something like

Fully drawn com.app/.MainActivity: +1.4s

too.

Production

Ideally PlayStore can optimize the bytecode better with more accurate TTFDs, and startup time should decrease, but that is speculation.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 3, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 3, 2026
@mrousavy

mrousavy commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Claude says you can inspect the generated profiles;

adb shell killall -s SIGUSR1 com.your.app   # force ART to save the profile
adb shell pm dump-profiles com.your.app     # writes readable dump to /data/misc/profman/
adb pull /data/misc/profman/com.your.app-primary.prof.txt

Haven't tried myself though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant