Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize startup by preventing whole screen recomposing twice #1369

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mlykotom
Copy link
Contributor

What I have done and why

I reworked the way how we set up the MainActivity wrt to theming and user settings.

This includes:

  • reacting to uiMode config change (before, the whole activity would be recreated when theme changed)
  • encapsulate the state logic into its class
  • prevent calling enableEdgeToEdge twice with different settings

This way I can get rid of one whole-screen recomposition, which is ~12ms on a Pixel 6.
image

Do tests pass?

  • Run local tests on DemoDebug variant: ./gradlew testDemoDebug
  • Check formatting: ./gradlew --init-script gradle/init.gradle.kts spotlessApply

@mlykotom mlykotom changed the base branch from main to mlykotom/offload-connectivity-monitor April 10, 2024 12:11
@mlykotom mlykotom changed the title Mlykotom/optimize startup Optimize startup by preventing whole screen recomposing twice Apr 10, 2024
Copy link

Combined test coverage report

Overall Project 39.98% -0.25%
Files changed 64.57% 🍏

Module Coverage
data 59.65% -5.52%
app 28.33% -0.25% 🍏
Files
Module File Coverage
data ConnectivityManagerNetworkMonitor.kt 0% -60.65%
app MainActivityViewModel.kt 90.38% -9.62% 🍏
UiExtensions.kt 81.93% -18.07% 🍏
MainActivity.kt 81.83% -1.23% 🍏

Change-Id: I8012c8b4544abc9488f96f6f01822fb15bb0775a
- Activity handles uiMode config change to prevent re-creating the whole activity
- Wrap uiState logic into its classes
- Optimize startup to prevent recomposing twice on startup
- Optimize startup to call enableEdgeToEdge only once or when change occurs

Change-Id: I6f7a48b3b6ce9b55db4ab2ec1770583028e9bc50
Copy link

Combined test coverage report

Overall Project 40.01% -0.05% 🍏
Files changed 90.27% 🍏

Module Coverage
app 28.33% -0.25% 🍏
Files
Module File Coverage
app MainActivityViewModel.kt 90.38% -9.62% 🍏
UiExtensions.kt 81.93% -18.07% 🍏
MainActivity.kt 81.83% -1.23% 🍏

Change-Id: I6b77e1c23ad91c1c97f31a705161d444be7913c0
Copy link

Combined test coverage report

Overall Project 40.05% -0.06% 🍏
Files changed 89.58% 🍏

Module Coverage
app 28.55% -0.28% 🍏
Files
Module File Coverage
app MainActivityViewModel.kt 90.38% -9.62% 🍏
UiExtensions.kt 81.93% -18.07% 🍏
MainActivity.kt 81.82% -2.02% 🍏

Change-Id: I54c9a794cbb84ffba4378ccc901ceb603de4642c
Copy link

Combined test coverage report

Overall Project 40.02% -0.06% 🍏
Files changed 89.58% 🍏

Module Coverage
app 28.55% -0.28% 🍏
Files
Module File Coverage
app MainActivityViewModel.kt 90.38% -9.62% 🍏
UiExtensions.kt 81.93% -18.07% 🍏
MainActivity.kt 81.82% -2.02% 🍏

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.

None yet

3 participants