Skip to content

Migrate app startup snippets - #1055

Open
pengzhi-cb wants to merge 7 commits into
android:mainfrom
StellarElements:katherinekuan/app-startup-snippets
Open

pengzhi-cb wants to merge 7 commits into
android:mainfrom
StellarElements:katherinekuan/app-startup-snippets

Conversation

@pengzhi-cb

@pengzhi-cb pengzhi-cb commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Code snippets are for:

  1. (3 snippets) https://developer.android.com/topic/performance/appstartup/analysis-optimization
  2. (2 snippets) https://developer.android.com/topic/performance/appstartup/best-practices

Total: 5 code snippets (3 unique Kotlin snippets and 0 XML snippets) across 2 pages.

List of modifications
  1. Analysis-optimization page: Replaced standalone ... placeholders with // ... comments and added braces { ... } around the if (BuildConfig.DEBUG) body in MyApplication.onCreate() (android_performance_appstartup_strict_mode).
  2. Analysis-optimization page: Normalized indentation to 4 spaces and added spaces inside { mutableStateOf(false) } in android_compose_performance_conditional_composition and android_compose_performance_conditional_composition_effect.
  3. Best-practices page: Consolidated duplicate conditional composition blocks with the Analysis-optimization page by sharing android_compose_performance_conditional_composition and android_compose_performance_conditional_composition_effect in PerformanceSnippets.kt, and normalized indentation from 3 spaces to 4 spaces.
Snippets not migrated
  1. Analysis-optimization page:
    1. None (all 3 snippets on the guide page were migrated).
  2. Best-practices page:
    1. None (all 2 snippets on the guide page were migrated).

@pengzhi-cb
pengzhi-cb requested a review from a team as a code owner August 28, 2026 13:54
@pengzhi-cb
pengzhi-cb requested a review from bsagmoe August 28, 2026 13:54
@snippet-bot

snippet-bot Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 3 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@google-cla

google-cla Bot commented Aug 28, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pengzhi-cb
pengzhi-cb marked this pull request as draft August 28, 2026 14:05
@pengzhi-cb
pengzhi-cb force-pushed the katherinekuan/app-startup-snippets branch from 3e6e001 to 8f5c282 Compare August 28, 2026 14:29
@pengzhi-cb
pengzhi-cb marked this pull request as ready for review August 28, 2026 14:37
@kkuan2011
kkuan2011 requested a review from AjeshRPai August 28, 2026 15:51
@kkuan2011

Copy link
Copy Markdown
Contributor

Thanks Peng, could you rename the title of the PR to something like Migrate performance snippets? Also feel free to remove any comments in the PR description if it refers to intermediate states of the PR and is not reflected in the final code (e.g. mentions of System.gc() can be removed now). I've also added our Performance DRE, Ajesh, for review on the PR too.

@pengzhi-cb pengzhi-cb changed the title Katherinekuan/app startup snippets Migrate performance snippets Aug 28, 2026
@pengzhi-cb

pengzhi-cb commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks Peng, could you rename the title of the PR to something like Migrate performance snippets? Also feel free to remove any comments in the PR description if it refers to intermediate states of the PR and is not reflected in the final code (e.g. mentions of System.gc() can be removed now). I've also added our Performance DRE, Ajesh, for review on the PR too.

Got it, since the final diff wouldn't show those intermediary changes and it will be confusing to reviewer. Let me remove.

Comment thread compose/snippets/build.gradle.kts Outdated
// Disable unused AGP features
viewBinding = true

buildConfig = true

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.

actually instead of enabling this in the build file, can we handle this by declaring a mock object in the AnalysisOptimization file?

private object BuildConfig {
const val DEBUG = true
}

Because I think enabling this property can have build time implications for everyone using the snippets repo. And in the AGP 8.0 Release Notes, it looks like buildConfig is false by default to eliminate this compilation overhead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Revert in 6c8c78c

@pengzhi-cb
pengzhi-cb force-pushed the katherinekuan/app-startup-snippets branch from 8f5c282 to 6c8c78c Compare September 14, 2026 18:46
@pengzhi-cb pengzhi-cb changed the title Migrate performance snippets Migrate app startup snippets Sep 14, 2026

@kkuan2011 kkuan2011 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.

Looks good after comments are addressed

@kkuan2011

Copy link
Copy Markdown
Contributor

Looks good, thanks!

@kkuan2011
kkuan2011 removed the request for review from bsagmoe September 15, 2026 16:44
@pengzhi-cb
pengzhi-cb force-pushed the katherinekuan/app-startup-snippets branch from 670ac3a to 3574247 Compare October 7, 2026 12:50
kkuan2011 and others added 7 commits October 7, 2026 16:07
…anceSnippets

- Correct the package declaration in `AnalysisOptimization.kt` to match the directory structure
- Add proper curly braces to the `if (BuildConfig.DEBUG)` block in `AnalysisOptimization.kt`
- Relocate fake classes/methods to the bottom of `PerformanceSnippets.kt` and update the block comment style to standard syntax (`/* END Fakes */`)
@pengzhi-cb
pengzhi-cb force-pushed the katherinekuan/app-startup-snippets branch from 3574247 to c0d00b9 Compare October 7, 2026 16:08

This branch has not been deployed

No deployments
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