Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Bug 1858789 - vastly more efficient counting of bookmarks for the hom… #4077

Merged
merged 2 commits into from
Dec 12, 2023
Merged

Bug 1858789 - vastly more efficient counting of bookmarks for the hom… #4077

merged 2 commits into from
Dec 12, 2023

Conversation

mhammond
Copy link
Contributor

@mhammond mhammond commented Oct 13, 2023

…e activity.

Relies on mozilla/application-services#5853 which was very recently merged - hopefully the Nightlies job will see it 😅 .

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

  • Breaking Changes: If this is a breaking Android Components change, please push a draft PR on Reference Browser to address the breaking issues.

To download an APK when reviewing a PR (after all CI tasks finished running):

  1. Click on Checks at the top of the PR page.
  2. Click on the firefoxci-taskcluster group on the left to expand all tasks.
  3. Click on the build-apk-{fenix,focus,klar}-debug task you're interested in.
  4. Click on View task in Taskcluster in the new DETAILS section.
  5. The APK links should be on the right side of the screen, named for each CPU architecture.

GitHub Automation

https://bugzilla.mozilla.org/show_bug.cgi?id=1858789

@github-actions github-actions bot added the 🕵️‍♀️ needs review PRs that need to be reviewed label Oct 13, 2023
@@ -36,7 +36,7 @@ class BookmarkItemMenu(
@VisibleForTesting
@SuppressWarnings("LongMethod")
internal suspend fun menuItems(itemType: BookmarkNodeType, itemId: String): List<TextMenuCandidate> {
val hasAtLeastOneChild = !context.bookmarkStorage.getTree(itemId)?.children.isNullOrEmpty()
val hasAtLeastOneChild = !context.bookmarkStorage.getTree(itemId, false)?.children.isNullOrEmpty()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't technically part of the home activity changes, but while looking for other suspect uses of getTree I discovered this, which doesn't actually need the full content of each child but will work just fine with just the IDs of the children.

@jonalmeida
Copy link
Collaborator

@rahulsainani would you be interested in reviewing this patch? I see that you had written an extension function in this that does some clean-up so figured you might be curious to try this out.

As a further follow-up to BZ-1836447, we can reduce the HomeActivity by moving this out entirely and doing it some kind of telemetry observer that listens to lifecycle events. I'm not sure why we are doing this in onPause to begin with, but let's not change that part for now.

@rahulsainani
Copy link
Contributor

Apologies, i haven't been able to look at this till now. Just got pinged by Jeff so I've added him as reviewer.

Copy link
Contributor

@boek boek left a comment

Choose a reason for hiding this comment

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

Looks good! Could you add a Changelog entry before you merge? :)

@boek boek added approved PR that has been approved and removed 🕵️‍♀️ needs review PRs that need to be reviewed labels Nov 15, 2023
@mhammond mhammond added the 🛬 needs landing PRs that are ready to land label Nov 16, 2023
@mhammond
Copy link
Contributor Author

Thanks! Added a changelog entry and added a "needs landing" label, so I hope the rest takes care of itself :)

@jonalmeida jonalmeida removed the 🛬 needs landing PRs that are ready to land label Nov 16, 2023
@jonalmeida
Copy link
Collaborator

jonalmeida commented Nov 16, 2023

Thanks! Added a changelog entry and added a "needs landing" label, so I hope the rest takes care of itself :)

Removing the label, sorry! I see some legitimate failures in the linter task and a unit test failure with DesktopFoldersTest. countBookmarks (ignore the intermittent failures from the other tasks).

Copy link
Contributor

mergify bot commented Nov 20, 2023

This pull request has conflicts when rebasing. Could you fix it @mhammond? 🙏

1 similar comment
Copy link
Contributor

mergify bot commented Nov 22, 2023

This pull request has conflicts when rebasing. Could you fix it @mhammond? 🙏

@jonalmeida
Copy link
Collaborator

Spoke to mark offline and recommended two changes:

  • Let's remove the previous count() method so that we don't keep using it.
  • There is a failure in the unit test countBookmarks that is failing because of a long standing bug in mockk. Let's remove this test in that case, because it doesn't add enough value compared to trying to land it with a workaround for this test framework bug.
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class kotlin.UInt (java.lang.Integer is in module java.base of loader 'bootstrap'; kotlin.UInt is in unnamed module of loader 'app')

cc: @boek

Copy link
Contributor

🚧 Commit message is using the wrong format: remove count() method

The comment message should look like:

    Bug xxxx - Short description of your change
    Optionally, a longer description of the change.

Copy link
Contributor

mergify bot commented Dec 12, 2023

This pull request has conflicts when rebasing. Could you fix it @mhammond? 🙏

@mhammond
Copy link
Contributor Author

Best I can tell the only failures here are the ones main has.

@mhammond mhammond requested a review from boek December 12, 2023 18:30
Copy link
Collaborator

@jonalmeida jonalmeida left a comment

Choose a reason for hiding this comment

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

Cheers!

I left one comment below which I'll quickly fix myself so that we can land this now.

@@ -42,6 +43,7 @@ class DesktopFoldersTest {
fun setup() {
context = spyk(testContext)
every { context.components.core.bookmarksStorage } returns mockk()
coEvery { context.components.core.bookmarksStorage.countBookmarksInTrees(any()) } returns 0U
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line will throw errors if someone tries to make an assertion that executes this line in a future test. It might be best to remove it to avoid a footgun in the future.

@jonalmeida jonalmeida added the 🛬 needs landing PRs that are ready to land label Dec 12, 2023
@mergify mergify bot merged commit 79047f7 into mozilla-mobile:main Dec 12, 2023
122 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved PR that has been approved 🛬 needs landing PRs that are ready to land
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants