Skip to content

Conversation

@Luna712
Copy link
Contributor

@Luna712 Luna712 commented Nov 1, 2025

No description provided.

Copy link
Collaborator

@fire-light42 fire-light42 left a comment

Choose a reason for hiding this comment

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

After thoroughly reading your pull request, I several potential problems. Some motivation of how it improves performance, and correctness statements would be appreciated. ❤️

homeViewModel.queryTextSubmit("")
}

homeMasterRecycler.setHasFixedSize(true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure about this?

expandCallback?.invoke(name)
val currentAdapter = (binding.homeChildRecyclerview.adapter as? HomeChildItemAdapter)
?.apply {
if (isHorizontal != info.isHorizontalImages) isHorizontal = info.isHorizontalImages
Copy link
Collaborator

Choose a reason for hiding this comment

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

isHorizontal and hasNext is not an expensive operation? Why are you doing this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I was randomly trying things and it ended up in there when I opened the PR. That won't be in the final version.

expandCount = count
expandCallback?.invoke(name)
val currentAdapter = (binding.homeChildRecyclerview.adapter as? HomeChildItemAdapter)
?.apply {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You forgot to update the clickCallback, nextFocusUp and nextFocusDown. As sharedPool is shared between adapters this needs to always be set.

) {
// clear image to avoid loading & flickering issue at fast scrolling (e.g, an image recycler)
this.dispose()
if (imageData == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What? dispose stops the current request and clears the image. I do not see what advantage this brings. Moreover, will this not break if we do loadImage(url); loadImage(null) ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean to write

this.dispose()
this.setImageDrawable(null)

}
}

binding.homeChildRecyclerview.setRecycledViewPool(HomeChildItemAdapter.sharedPool)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that you should set the pool before attaching the adapter. I do not have a source for this, but I remember reading it.

}

binding.homeChildRecyclerview.setRecycledViewPool(HomeChildItemAdapter.sharedPool)
binding.homeChildRecyclerview.setHasFixedSize(true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please double check this. I am unsure if we can make such assumptions if we recycle the entire homeChildRecyclerview, but I have not checked.

companion object {
val sharedPool =
RecyclerView.RecycledViewPool().apply { this.setMaxRecycledViews(CONTENT, 4) }
RecyclerView.RecycledViewPool().apply { this.setMaxRecycledViews(CONTENT, 8) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason why this needs to be 8? This is the parent view for each row, not the items themself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because sometimes there are many rows. That was the intent anyway.

internal fun buildImageLoader(context: PlatformContext): ImageLoader = ImageLoader.Builder(context)
.crossfade(200)
.allowHardware(SDK_INT >= 28) // SDK_INT >= 28, cant use hardware bitmaps for Palette Builder
.allowHardware(SDK_INT >= 28) // SDK_INT < 28, can't use hardware bitmaps for Palette Builder
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you misinterpreted the comment. The comment is "SDK_INT >= 28" and "can't use hardware bitmaps for Palette Builder", they are unrelated, and it does not make any sense to switch >= to <. See 3636d8e

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh that was my had yeah whoops.

}

if(imageData == null) return // Just in case
// Only dispose if a different image is requested to avoid unnecessary reloads
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this really a thing that happens? Does dispose really show up in a flamegraph?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the idea was to not clear and reload the image every time but only if the actual source changes but its also possible I misinterpreted the intent behind dispose here.

adapter.hasNext = item.hasNext
adapter.submitList(info.list)

binding.homeChildRecyclerview.addOnScrollListener(object : RecyclerView.OnScrollListener() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same problem as the You forgot to update the clickCallback

@Luna712
Copy link
Contributor Author

Luna712 commented Nov 1, 2025

After thoroughly reading your pull request, I several potential problems. Some motivation of how it improves performance, and correctness statements would be appreciated. ❤️

Thanks for the review alot I hadn't yet considered, but for the record I only opened this PR so that I could just put it out here, it was far from finished which is why I marked as a draft. I was trying to reduce the lag on the home page on some devices so I was trying things. Coil seems to be a major part of the expensive operations also, and setHasFixedSize can help also, but you also make a point if that is okay to do. I'm almost certain it should be fine on the master recycler, less so on the child ones. (or maybe I'm in reverse here and its the other way around).

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