Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

For #11753 - Update compose to 1.1.1 and Kotlin to 1.6.10 #12000

Merged
merged 3 commits into from
Apr 18, 2022

Conversation

Mugurell
Copy link
Contributor

This also required updating room to >= 2.4.0.
This new version adds a deprecation of the MigrationTestHelper api used in
LoginExceptionStorageTest that is to be later fixed in #11765.

activity_compose was also updated to the latest stable version to ensure a
better match with the latest stable version for compose.

Most of the changes are around supporting exhaustive whens for sealed classes as a new kotlin feature - https://kotlinlang.org/docs/whatsnew1530.html#exhaustive-when-statements-for-sealed-and-boolean-subjects

Updating kotlin-coroutines will be a followup - #11755

This should help fix mozilla-mobile/fenix#23989 - stress tested the scenario that I found to reproduce that crash and it doesn't happen anymore but more tests are needed before landing the updates at once on all projects.

Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or does not need one
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues closed by this pull request are added to the milestone of the version currently in development.
  • Breaking Changes: If this is a breaking change, please push a draft PR on Reference Browser to address the breaking issues.

@@ -36,30 +35,25 @@ internal fun Suggestions(
state = state,
modifier = Modifier.testTag("mozac.awesomebar.suggestions")
) {
val suggestions = fetcher.state.value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think not having this fetcher that would update the data to display as a property inside of LazyColumn that would also recompose when the data changes would be the most important improvement.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I fully understand this change :). Don't need to block on it, but curious if you could share more?

Copy link
Contributor Author

@Mugurell Mugurell Apr 15, 2022

Choose a reason for hiding this comment

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

The update to a newer compose version definitely played a part but I would also put it on the fact that here we have a recomposition loop (not bad bad but bad enough - https://developer.android.com/jetpack/compose/phases#recomp-loop) and the fact that composable functions can run in parallel - https://developer.android.com/jetpack/compose/mental-model#parallel.

Not sure what synchronization mechanisms are used to prevent issue with running composables in parallel but just speculating that it may be possible that because fetcher.state.value is read in Suggestions it may happen that any change in the value will trigger:

  • a recomposition of the items shown (the composables which adapts those values)
  • this will trigger a recomposition of the parent - Suggestions
  • Suggestions will again read the value from fetcher.state.value. (We should've used remember{} to prevent this)
  • the items shouldn't recompose since the actual value didn't change but maybe it did in the meantime.

Maybe these updates happen in less than a frame and recompositions didn't have time to handle it all, maybe the states are updated and a new composition is driven by different cores which may have out of sync values.
There are many "maybe"s but by moving that code for observing state out of the composable that should display the state the code becomes cleaner, more in line with Compose's direction of passing state down to be displayed - https://developer.android.com/jetpack/compose/state and hopefully skips some recompositions or at least leads a more direct line of updates, without that loop I talked about above.

@csadilek csadilek added the do not land PRs that requires coordination before landing label Apr 13, 2022
Copy link
Contributor

@csadilek csadilek left a comment

Choose a reason for hiding this comment

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

Just putting the do not land label on re:

This should help fix mozilla-mobile/fenix#23989 - stress tested the scenario that I found to reproduce that crash and it doesn't happen anymore but more tests are needed before landing the updates at once on all projects.

@Mugurell When you write "more tests needed" did you mean prior to landing this or are you confident already? In either case we should land this on Monday or early in the week in case those crashes do come back.

@@ -37,6 +37,7 @@ class LoginExceptionStorageTest {
var instantTaskExecutorRule = InstantTaskExecutorRule()

@get:Rule
@Suppress("DEPRECATION")
Copy link
Contributor

Choose a reason for hiding this comment

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

what's throwing the "deprecation" warning here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left a note in the commit message. The constructor used there will become deprecated following the room version update. To be handled in #11765.

@Mugurell
Copy link
Contributor Author

Just putting the do not land label on re:

This should help fix mozilla-mobile/fenix#23989 - stress tested the scenario that I found to reproduce that crash and it doesn't happen anymore but more tests are needed before landing the updates at once on all projects.

@Mugurell When you write "more tests needed" did you mean prior to landing this or are you confident already? In either case we should land this on Monday or early in the week in case those crashes do come back.

I didn't find a clear cause or clear steps to reproduce that crash but found a general scenario that would trigger it "most of the time" in under 5 minutes (usually <1/2/3 minutes).
With this speculative fix it didn't crash anymore though I tried the same scenario for 30 minutes.
These tests were done with the repos at the state when the crash happened.
Will rebase everything and test again with my fingers crossed.
Then I agree that we should try to land at the beginning of the next week to have a few days for observation and be able to quickly revert if needed.

This also required updating room to >= 2.4.0.
This new version adds a deprecation of the `MigrationTestHelper` api used in
`LoginExceptionStorageTest` that is to be later fixed in mozilla-mobile#11765.

`activity_compose` was also update to the latest stable version to ensure a
better match with the latest stable version for compose.

Used 1.6.10 for Kotlin although 1.6.20 is available to prevent any issues with
Compose 1.1.1 reported as an error at compile time:
"e: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10
but you appear to be using Kotlin version 1.6.20 which is not known to be
compatible.  Please fix your configuration (or
`suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!)."
@Mugurell
Copy link
Contributor Author

Tested again with this applied on latest main and it seems like the crash dissapeared. 🤞

@Mugurell Mugurell mentioned this pull request Apr 14, 2022
4 tasks
Copy link
Member

@gabrielluong gabrielluong left a comment

Choose a reason for hiding this comment

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

Compose changes look good to me. I did review the entire PR to be clear.

@Mugurell Mugurell changed the title For #11753 - Update compose to 1.1.1 and Kotlin to 1.6.20 For #11753 - Update compose to 1.1.1 and Kotlin to 1.6.10 Apr 14, 2022
@Mugurell
Copy link
Contributor Author

Confirmed with Christian that we can land this and keep a close eye on Sentry.

@Mugurell Mugurell added 🛬 needs landing PRs that are ready to land and removed do not land PRs that requires coordination before landing labels Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🛬 needs landing PRs that are ready to land
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Crash] IndexOutOfBoundsException calling SafeIntentKt.intervalIndexForItemIndex
4 participants