Skip to content

ADFA-7068 | Speed up Compose Preview and fix lost edits, ClassNotFoundException and comment parsing - #161

Open
Daniel-ADFA wants to merge 2 commits into
mainfrom
fix/ADFA-7068-compose-preview-speed
Open

Daniel-ADFA wants to merge 2 commits into
mainfrom
fix/ADFA-7068-compose-preview-speed

Conversation

@Daniel-ADFA

@Daniel-ADFA Daniel-ADFA commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

ADFA-7068

Jetpack Compose Preview plugin:

  • Keep one compiler daemon for the plugin and warm it when a Compose file is shown, instead of starting a cold one for every preview.
  • Call D8 through D8Command.parse(String[], Origin). The old reflective call named a method that does not exist, so dexing always fell back to a second JVM.
  • Clear the class output folder before each compile.
  • Save the open file before opening the preview. Adds the filesystem.write permission.
  • Dex the project's compiled classes in the plugin and key the preview cache on them. Quick Build rewrites the build's dex output without them, which caused ClassNotFoundException at render.
  • Show the reason when a build is refused, and point at an unbuilt project on unresolved references.
  • Ignore comments when looking for @Preview.

Pixel 9 Pro, median tap to preview loaded after an edit: 6.1 s to 0.6 s (14 lines), 11.4 s to 1.9 s (98 lines), 18.5 s to 4.5 s (1,214 lines).

Limits: the daemon stops after 5 idle minutes, so the next preview is cold again. @Preview inside a string literal is still matched. The plugin has no unit tests; the parser change was checked with a script outside the repo.

…dException and comment parsing

Keep one compiler daemon for the plugin instead of one per preview screen,
and warm it when a Compose file is shown. Call D8 through the API that
exists so dexing stays in the daemon. Clear the class output folder before
each compile.

Save the open file before opening the preview (adds filesystem.write).

Dex the project's compiled classes in the plugin and key the preview cache
on them, because Quick Build rewrites the build's dex output without them.

Show why a build was refused, point at an unbuilt project on unresolved
references, and ignore comments when looking for @Preview.
@Daniel-ADFA
Daniel-ADFA requested a review from a team November 10, 2026 14:59

@hal-eisen-adfa hal-eisen-adfa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review comments from reading the code. None has been reproduced on a device yet.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants